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

The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none

761


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

630


Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.

681


Is there any data type in c with variable size?

630


what is a NULL Pointer? Whether it is same as an uninitialized pointer?

758






What language is lisp written in?

617


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1326


Is c dynamically typed?

667


hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..

1467


Is c procedural or object oriented?

579


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1257


Why header files are used?

643


Is python a c language?

550


What does printf does?

742


Write a program to show the change in position of a cursor using c

579