int main() { int x=3; cout<<(x<5) +1; return 0; } | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

int main() { int x=3; cout<<(x<5) +1; return 0; }

Explain the output please

1st Jul 2017, 2:53 AM
Kushagra Agarwal
Kushagra Agarwal - avatar
2 Answers
+ 1
cout<<(x<5)+1; here x<5 ,so the output will be 1. the final answer will be 2 [cout<<(1)+1] if x<5 statement is true output will be 1 if it is false output will be 0 (its like bool)
1st Jul 2017, 3:18 AM
‎ ‏‏‎Anonymous Guy
+ 1
for argument: non-zero = true zero = false for output: true = 1 false = 0
1st Jul 2017, 2:59 AM
K.C. Leung
K.C. Leung - avatar