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 does struct node * mean?

602


Can you pass an entire structure to functions?

696


How can you increase the size of a statically allocated array?

616


How can you find the day of the week given the date?

617


Why is event driven programming or procedural programming, better within specific scenario?

1955






Is array a primitive data type in c?

579


What is sizeof int?

637


Write a program for finding factorial of a number.

635


What is the difference between arrays and pointers?

636


Explain how can I remove the trailing spaces from a string?

625


What is the difference between a function and a method in c?

560


what is the difference between class and unio?

1862


What does a function declared as pascal do differently?

607


Do you know null pointer?

611


What is c system32 taskhostw exe?

592