Find greatest number out of 10 number without using loop.
Answers were Sorted based on User's Feedback
Answer / ashwin
#include<stdio.h>
int MAX(int a,int b)
{
if(a>b)
return a;
else
return b;
}
int max(int a[],int n)
{
if(n==1)
return a[0];
else
return MAX(a[n-1],max(a,n-1));
}
int main()
{
int a[]={3,5,1,5,7,3,9,0,2,6};
int n=10,big;
big=max(a,n);
printf("%d",big);
return 0;
}
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / dheeraj
#include<stdio.h>
#include<conio.h>
input(int a[]);
find(int []);
int i=0,a[10],j=0,max=0;
main()
{
clrscr();
printf("enter no");
input(a);
find(a);
printf("\nmax no is==%d",max);
}
input(int a[10])
{
i++;
scanf("%d",&a[i]);
if(i<10)
{
input(a);
}
}
find(int a[10])
{
if(j<10)
{
j++;
if(max<a[j])
{
max=a[j];
}
find(a);
}
}
Is This Answer Correct ? | 9 Yes | 8 No |
Answer / khurshid alam
#include<stdio.h>
int show();
int main()
{
printf("The bigger value is:%d",show());
}
int show()
{
static int big=0,a=0,c=0;
printf("enter number");
scanf("%d",&a);
if(a>big)
big=a;
if(c<=10)
{
c++;
show();
}
return big;
}
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / satya
#include<stdio.h>
void main()
{
static int big=0,a=0,cnt=0;
printf("enter number");
scanf("%d",&a);
if(a>big)
big=a;
if(cnt<=10)
{
cnt++
main();
}
printf("largest number amongest 10 numbers is :%d",big);
}
Is This Answer Correct ? | 4 Yes | 11 No |
Answer / joshi
/* for same qustion this */
void main()
{
int a,b;
clrscr();
printf (enter the two number :);
scanf("%d%d",a,b);
if (a>b)
printf ("%d\n greater number",a);
else
printf ("%d\n greter number",b);
getch();
}
Is This Answer Correct ? | 11 Yes | 48 No |
who did come first hen or agg
In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
du u know test pattern for robosoft? Plz share
1 Answers RoboSoft, TATA, Wipro,
Can two or more operators such as and be combined in a single line of program code?
const char * char * const What is the differnce between the above tow?.
Write a program to print “hello world” without using semicolon?
explain how do you use macro?
what is difference between userlevel threads and kernel level threads ?what are the trades offs between these two approaches ? what approach is most frequently used and why ?
write a c code "if you give a any decimal number then print that number in english alphabet"? ex: i/p: 552 o/p: five hundred fifty two ...
Is it valid to address one element beyond the end of an array?