+ 3
Int x=1,y=2,z=0; if(x!=y>z) cout<<"1"; else cout<<"0";
Why answer is 0 ?
3 Answers
+ 2
y>z returns true and x!=true is obviously false .
+ 2
Operator > has higher precedence over operator !=. So `y > z` is evaluated first, and then the result (true or value 1) is used as the right hand side operand for evaluation of `x != z`.
Obviously `x != 1` is evaluated as false because <x> value is 1, and that's how we ended up executing the `else` block.
+ 1
Int x=1,y=2,z=0;
if(x!=y>z)
cout<<"1";
else cout<<"0";
You defined two variable and in if condition you have written
if(x!=y>z) here y>z which is true so it will return 1 so
If(1!=1 ) here 1==1 so it true but here u have written not equal (!=) Which will make condition false ao else part will be execute and result 0 will be print.