This program is running good, the problem is that is suppose to print the smallest and largest, but sometimes it just prints the largest and sometimes it prints the smallest. I want both of them to be printed at the end. I want to do this program with if and if else... can one help me.
Fell free to give me your opinions and what my mistakes are. Thank you Very Much
Code:
/* Write a program that reads in four integers and determines and
prints the largest and the smallest integeers in the group.
*/
#include <stdio.h>
int main()
{
int a,b,c,d,e;
printf( "Enter number for 'ONE':\n" );
scanf( "%d", &a );
printf( "Enter number for 'TWO':\n" );
scanf( "%d", &b );
printf( "Enter number for 'Three':\n" );
scanf( "%d", &c );
printf( "Enter number for 'Four':\n" );
scanf( "%d", &d );
printf( "Enter number for 'Five':\n" );
scanf( "%d", &e );
if (a > b && a > c && a > d && a > e)
printf( "%d is the largest number\n", a);
else if(a < b && a < c && a < d && a < e)
printf( "%d is the smallest number\n", a);
else if(b > a && b > c && b > d && b > e)
printf( "%d is the largest number\n", b);
else if(b < a && b < c && b < d && b < e)
printf( "%d is the smallest number\n", b);
else if(c > a && c > b && c > d && c > e)
printf( "%d is the largest number\n", c);
else if(c < a && c < b && c < d && c < e)
printf( "%d is the smallest number\n", c);
else if(d > a && d > b && d > c && d > e)
printf( "%d is the largest number\n", d);
else if(d < a && d < b && d < c && d < e)
printf( "%d is the smallest number\n", d);
else if(e > a && e > b && e > c && e > d)
printf( "%d is the largest number\n", e);
else if(e < a && e < b && e < c && e < d)
printf( "%d is the smallest number\n", e);
return 0;
}