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"); }

16th Feb 2019, 12:00 AM
Shaik Abeedh
Shaik Abeedh - avatar
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
16th Feb 2019, 1:24 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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.
16th Feb 2019, 12:24 AM
LynTon
LynTon - avatar