This may not be the best way to do this but as I think you’re learning I won’t try to mess with your logic too much. I will solve two problems existing in it.
The first is that you can’t make a complex comparison. The computer works like our brain, it does one operation at a time. It cannot buy if 3 numbers one is smaller than the other. You can only compare two numbers at a time. You make a comparison and then you make another comparison and then you make another one that brings the two together. This operation that will join the two is the "And logical", that is, both operations must be true for everything to be true. In C the operator responsible for this is the &&
.
The second problem is that you haven’t checked all the order possibilities.
Is there another problem that the code is poorly organized perhaps because you don’t know the else if
which it performs if the previous condition is false. But it already checks another condition. It can be done without the else if
, just eliminate all the else
s and make the if
s independent. Still you can do it differently and more optimized (just reordering the sequence of each condition would already optimize a little), but I will not complicate for you. I think I’m already introducing several new concepts.
Would look like this:
#include <stdio.h>
int main (void) {
int A, B, C;
scanf("%d %d %d", &A, &B, &C);
if (A < B && B < C) printf("%d %d %d", A, B, C);
else if (C < B && B < A) printf("%d %d %d", C, B, A);
else if (B < A && A < C) printf("%d %d %d", B, C, A);
else if (A < C && C < B) printf("%d %d %d", A, C, B);
else if (B < A && A < C) printf("%d %d %d", B, A, C);
else if (C < A && A < B) printf("%d %d %d", C, A, B);
}
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.