Pages

Sunday, November 15, 2015

C Program to find min and max of given numbers using array

Program

#include<stdio.h>
void main()
{
int a[10];
int i,min,max;
printf("Enter 10 nos : ");
for(i=0;i<10;i++)
scanf("%d",&a[i]);

max=min=a[0];

for(i=1;i<10;i++)
{
if(min>a[i])
min=a[i];
if(max<a[i])
max=a[i];
}

printf("Min= %d, Max= %d",min,max);

}

Output

Enter 10 nos : 3
67
95
485
525
214
65
75
96
24
Min= 3, Max= 525

No comments:

Post a Comment