Saturday, January 8, 2011

C Program to find Largest number of 'n' numbers

Coding:

#include<stdio.h> 
#include<conio.h> 
void main()
{
int n,m,i,max;
clrscr();
printf("\nHow many numbers are you going to enter:");
scanf("%d",&n);
printf("\nEnter the numbers:\n");
textcolor(YELLOW);
scanf("%d",&m);
max=m;
for(i=2;i<=n;i++)
{
scanf("%d",&m);
if(m>max)
max=m;
}
cprintf("\nThe Largest Number is ");
textcolor(GREEN);
cprintf("%d",max);
getch();
}

Output:


No comments: