+ 1
Why is output 1 ??
int x=0; int y=0; int z=(x==y); cout<<(z==(y!=z));
3 Answers
+ 4
⢠(x == y) returns 1 (true) if x is equal to y, which is the case here.
⢠In the next line, (y != z) returns 1 (true) because the value of y is zero while z is one.
⢠Now, z == (y != z) is an equivalent expression to (z == 1) which returns 1 as it's true.
Something to keep in mind would be to use the code playground and post a link here instead of writing it in the Q/A section. (Not really needed for this particular one, just a suggestion.)
+ 3
z=1
y!=z returns 1
and z==1 is true so answer is 1
+ 2
y is 0, z is 1. So y!=z is true(1)