0
question in C programming language
I have encountered a question in C programming language and I was wrong in that question. int x = 10, y = 20, z = 5, i; i = x < y < z; printf("%d\n", i); That code outputs "1" and I can't understand why. May anyone explain me why is i equals 1?
3 Respostas
+ 4
When a comparison is true it returns 1. When it's false it returns 0.
The first comparison x<y is true, so 1
The second is 1<z which is true and so 1
i = 1
+ 3
x<y is true so it returns 1.
1<z is true so it again returns 1.
+ 2
Ok thanks!