This may not be the best way to do this but as I think you are learning I will not try to mess around with your logic. I will solve two problems in it.
The first is that you can not make a complex comparison. The computer works like our brain, it does one operation at a time. He can not 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 make another comparison and then do another one that brings the two together. This operation that will join the two is the "logical AND", that is, both operations must be true for everything to be true. In C the operator responsible for this is &&
.
The second problem is that you have not checked all order possibilities.
There is another problem that the code is poorly organized perhaps because you do not know the else if
that executes if the previous condition is false. But she already sees another condition. You can do without else if
, just delete all else
s and make if
s independent. Still it has how to do of another way and more optimized (only to reorder the sequence of each condition already would optimize a little), but I will not complicate for you. I think I'm already introducing several new concepts.
It 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) { //Se A for menor que B e se B for menor que C, A é o menor e C é o maior
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);
}
return 0;
}
See working on ideone .