C program to find largest number in an array
#include<stdio.h>
#include<conio.h>
void main()
{
int n, num[100], i, max;
printf("\n Enter a number:");
scanf("%d",&n);
printf("\n Enter %d numbers:",n);
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
max=num[0];
for(i=0;i<n;i++)
{
if(num[i]>max)
{
max=num[i];
}
}
printf("\n largest number=%d",max);
getch();
}
Output
In this program, users have to give how many numbers that is store in variable n and have to give total numbers.


0 Comments
Please do not enter any spam link on comment box