HOW TO: Determine Minimum & Maximum Number in C Programming
SOURCE CODE
#include <stdio.h>
int main()
{
int i, number[3], MIN, MAX;
for(i=0; i<3; i++)
{
printf("Enter number: ");
scanf("%d", &number[i]);
}
MIN=number[0];
MAX=number[0];
for(i=0; i<3; i++)
{
if(number[i]<MIN)
MIN=number[i];
if(number[i]>MAX)
MAX=number[i];
}
printf("Maximum: %d", MAX);
printf("\nMinimum: %d", MIN);
Comments
Post a Comment