0
Why the output coming as one?
int x=2, y=10,z=7,a; a=x<y<z; cout<<a; //This question was asked in post on FB....
2 Answers
+ 4
First, the expression
x < y
is evaluated, which is obviously true. Since only similar data types can be compared, the result is implicitely casted to 1 (the typical boolean representation of 'true', although any numerical non-zero value is considered as true in C++), which is then compared to 'z' in
1 < z
which is once again true.
The variable 'a' is then assigned this result after another implicit conversion.
0
Thanks Shadow .....I was evaluating the expression from the right n was guessing 0 as answer.... But now I feel dumb that I was evaluating it from right rather than left