Apr 19, 2013

C program to find maximum number from array of ten numbers


#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],max=0,i;
clrscr();
for(i=0;i<=9;i++)
{
printf("enter the number:");
scanf("%d",&a[i]);
}
for(i=0;i<=9;i++)
{
printf("a[%d]=%d\n",i,a[i]);
if(max<a[i])
{
max=a[i];
}
}
printf("the maximum is %d",max);
getch();
}

OUTPUT


enter the number:21
enter the number:45
enter the number:26
enter the number:35
enter the number:44
enter the number:66
enter the number:58
enter the number:12
enter the number:32
enter the number:52
a[0]=21
a[1]=45
a[2]=26
a[3]=35
a[4]=44
a[5]=66
a[6]=58
a[7]=12
a[8]=32
a[9]=52
the maximum is 66



0 comments:

Post a Comment