+ 1

Why does this output 0??

I can't figure out how the output becomes 0 in the code below. Can someone please help me out? (C++) int x = 5; cout << (x>5 || (x==5 && x==6 || x<5));

21st Jul 2020, 2:03 AM
InDeedOut
InDeedOut - avatar
3 Answers
+ 2
x>5=0 (x==5)=1 && (x==6)=0 ..1&&0=0 x<5=0 0||(0||0)=0..
21st Jul 2020, 2:44 AM
Aniket Chaudhary
Aniket Chaudhary - avatar
+ 4
Put the value of x in whole expression and see why it giving 0 . Here all conditions are failed so output is 0
22nd Jul 2020, 6:12 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
0 is false and the expression is evaluated as false.
21st Jul 2020, 2:07 AM
Sandra Meyer
Sandra Meyer - avatar