Int x=4 ; cout <<x<<++x<<++x; the output is 666 why ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Int x=4 ; cout <<x<<++x<<++x; the output is 666 why ?

18th Dec 2016, 9:58 PM
Rana
Rana - avatar
3 Answers
+ 6
because the two ++ operations takes predecence and ONLY AFTER them the x's are printed
18th Dec 2016, 10:07 PM
Burey
Burey - avatar
0
thanks 😊
18th Dec 2016, 10:29 PM
Rana
Rana - avatar
0
switch the ++ to after the x that should produce the results I think you are looking for
19th Dec 2016, 3:38 AM
John V Jokoty III
John V Jokoty III - avatar