Sunday, November 28, 2010

Write a program that reads in four integers and determines and prints the largest and the smallest integers in the group?

#include

#include



#define MAX_INTS 4



int main()

{

int min = INT_MAX;

int max = INT_MIN;

int a[ MAX_INTS ];

int i;



for (i = 0; i < MAX_INTS; i++)

{

printf( "Enter number %d of %d : ", (i + 1), MAX_INTS);

scanf( "%d", &a[i] );



if ( a[i] < min) min = a[i];

if ( a[i] > max) max = a[i];

}



printf("%d is the smallest number\n", min);

printf("%d is the largest number\n", max);



return 0;

}