+ 1

What is the output of this code

int x=3; if(x==2) cout<<"0"; else { cout<<"4"; cout<<"(x<5)+1; }

10th Nov 2017, 3:47 PM
Deep Prakash Goyal
Deep Prakash Goyal - avatar
10 Answers
+ 1
#cloudcoder what is the error in this code plz tell me
10th Nov 2017, 4:08 PM
Deep Prakash Goyal
Deep Prakash Goyal - avatar
+ 8
this works fine: int x=3; if(x==2) cout<<"0"; else { cout<<"4"; cout<<(x<5)+1; }
10th Nov 2017, 4:07 PM
Asiri H
Asiri H - avatar
+ 6
error
10th Nov 2017, 4:06 PM
Asiri H
Asiri H - avatar
+ 5
You can use your questions by writing them as quiz questions. Writing in here and asking other people is not an appropriate behaviour!
4th Jan 2018, 11:28 AM
Yunus
+ 2
I have posted the error free code above
11th Nov 2017, 1:15 PM
Asiri H
Asiri H - avatar
+ 1
#cloudcoder how?
10th Nov 2017, 4:07 PM
Deep Prakash Goyal
Deep Prakash Goyal - avatar
+ 1
The code from CloudCoder works. output 42.
10th Nov 2017, 5:15 PM
Paul
Paul - avatar
+ 1
(x < 5) is true, so it is 1 and then you add 1 that makes 2.
10th Nov 2017, 6:03 PM
Paul
Paul - avatar
+ 1
@Deep you have write: ...cout<<"(x <5)... buy you mustn't use quote here. it must be: ...cout<<(x <5)... like @CloudCoder said.
4th Jan 2018, 9:34 PM
Muhammed Can KÜÇÜKASLAN
Muhammed Can KÜÇÜKASLAN - avatar
0
#paul jacobs plz explain about 2 in this code
10th Nov 2017, 5:34 PM
Deep Prakash Goyal
Deep Prakash Goyal - avatar