C program to find largest number among n-digits.

01 #include<stdio.h>
02
03 int main()
04 {
05 int max_num(int a[],int n);
06 int max,i,n;
07 int a[50];
08
09 printf("Enter n number:");
10 scanf("%d",&n);
11 printf("Enter the numbers:");
12 for(i=0; i<n; i++)
13 scanf("%d",&a[i]);
14 max=max_num(a,n);
15 printf("The largest number is %d",max);
16
17 return 0;
18 }
19
20 int max_num(int a[],int n)
21 {
22 int i,m=0;
23 for(i=0; i<n; i++)
24 {
25 if(a[i]>m)
26 m=a[i];
27 }
28 return m;
29 }
 
OUTPUT :


Enter n number:5
Enter the numbers:12
22
43
55
17
The largest number is 55

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *