Write a program which reads 10 real numbers. The program must then show the maximum and the minimum of these numbers.
Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
#include<limits.h>
int main()
{
int i;
double x, min, max;
min = INT_MAX;
max = INT_MIN;
for(i=1;i<=10;i++)
{
printf("Enter number %2d : ",i);
scanf("%lf",&x);
if(x>max)
max = x;
if(x<min)
min = x;
}
printf("Max = %.4lf\tMin = %.4lf\n",max,min);
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
UVA 1112 - Mice and Maze