0
I get output as false why. Explain
#include <stdio.h> int main() { int x=8,y=14,z=29; if(z>y>x) printf("true"); else printf("false"); }
2 Antworten
+ 5
z>y is true. True exists as 1 in C. 1>8 is false. Therefore, false is returned.
You can do this if you want z>y>x:
z>y&&y>x
+ 4
First "z > y" is evaluated which is "29 > 14" which is true.
Then you have "true > 8", when use in a comparison "true" is converted to the number "1" so "1 > 8" evaluates to false hence the output.