0

Pls explain the last line (i.e:cout<<(x<5)+1;)

{int x=3; If(x==2) cout<<"0"; else cout<<"4"; cout<<(x<5)+1;} ....Ans:42

23rd Dec 2022, 6:44 PM
Mohammad Tausiful Alam
Mohammad Tausiful Alam - avatar
3 Answers
+ 1
booleans FALSE and TRUE are 0 and 1 so TRUE is 1 and FALSE is 0 so since (x < 5) is TRUE it becomes 1 and 1 + 1 is 2
23rd Dec 2022, 7:11 PM
Vanessa Nilsson
+ 2
x<5 is True means 1 as int type. So 1+1 = 2 is printed. Else part prints 4 before.
23rd Dec 2022, 7:09 PM
Jayakrishna šŸ‡®šŸ‡³
0
Thanks to all.Got itšŸ¤Ÿ
23rd Dec 2022, 7:19 PM
Mohammad Tausiful Alam
Mohammad Tausiful Alam - avatar