I have an exercise where I need to put four numbers in ascending order and then descending without using arrays. I can only use loops and if statements. I've done it with three numbers, but now with four numbers I am unable to think of the logic.
float great1 = 0, great2 = 0, great3 = 0, great4 = 0;
int a = 7, b = 5, c = 6, d = 0;
// Descending
if (a > b && b > c) {
great1 = a;
great2 = b;
great3 = c;
} else if (a > b && b < c) {
great1 = a;
great2 = c;
great3 = b;
} else if (b > a && a > c) {
great1 = b;
great2 = a;
great3 = c;
} else if (b > a && a < c) {
great1 = b;
great2 = c;
great3 = a;
} else if (c > a && a > b) {
great1 = c;
great2 = a;
great3 = b;
}
else {
great1 = c;
great2 = b;
great3 = a;
}