+ 3
A simple problem
int a=-2,b=-1,c=0; if(a<b<c){ printf("TRUE\n"); }else{ printf("FALSE\n"); } //the end I have no idea why/how the output is FALSE
7 Réponses
+ 17
in. if (a<b<c)
-2<-1 true
so this results in 1 (boolean)
1<0 false
so output FALSE
+ 17
ok.😉👌
+ 16
In C/C++
if comparison operators(<, >, ==, !=,<=, >=) applied on integers, strings , etc results in
1 --> true
0 --> false
+ 15
@🌛DT🌜 thank yu for yur explanation . so if i have a well understanding, yu mean that (a <b ) has created a boolean value 1 which was compared with the value 0 of c ?
+ 11
@hans Yes u got the point 👍😉
+ 3
thank you guys for explaining this, it was in my MCQ 😂😂 no one explained how boolean works with this kind of conditions in class😅😅
You guys are awesome. Thanks again.
+ 1
you can mix Boolean with integer values?