Find greatest number out of 10 number without using loop.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is "Duff's Device"?

709


What is a pointer on a pointer in c programming language?

629


Explain how do you list files in a directory?

626


What is the value of h?

608


List some applications of c programming language?

566






What are global variables and how do you declare them?

627


what type of questions arrive in interview over c programming?

1567


Define the scope of static variables.

614


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

1596


explain what are actual arguments?

645


What is exit() function?

570


write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);

1856


What is the difference between arrays and pointers?

642


Where are some collections of useful code fragments and examples?

725


How many bytes is a struct in c?

734