Calculate minimum and maximum number

minimum and maximum number among many numbers
‪#‎include‬<stdio.h>
#include<conio.h>
void main()
{

int n,x,c=0,max,min;
printf("\n how many numbers you want=");
scanf("%d",&n);
printf("\n enter a number -\n");
scanf("%d",&x);
max=x;
min=x;
c++;
while (c<n)
{printf("\n enter next number=");
scanf("%d",&x);
c++;
if(max<x)
{max=x;}
else if(min>x)
{min=x;}
}
printf("maximum number=%d,minimum=%d",max,min);
getch();
return;
}

Post a Comment

0 Comments