Pages

Sunday, November 15, 2015

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

Program

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

max=min=a[0].no;

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

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

}

Output
Enter 10 nos : 22
65
75
24
52
65
35
48
67
25
Min= 22, Max= 75

No comments:

Post a Comment