Hi, I'm trying to figure out where it goes wrong, but I still can't. This program aims to find min and max values among the 4 integers entered by the user. This is a programming exercise from King's book. Could you please help? Thanks a lot!!!
Code:
// Programming Project 5.7
#include<stdio.h>
int main(void)
{
int a = 0, b = 0, c = 0, d = 0;
int max = 0, min = 0;
printf("Enter 4 integers: ");
scanf("%d%d%d%d", &a, &b, &c, &d);
if(a > b && b > c && c > d) {
max = a;
min = d;
}
else if (b > c && c > d && d > a) {
max = b;
min = a;
}
else if(c > d && d > a && a > b) {
max = c;
min = b;
}
else if(d > a && a > b && b > c) {
max = d;
min = c;
}
printf("Largest: %d\nSmallest: %d\n", max, min);
return 0;
}