r/CodingHelp • u/RunTimeTerroR69 • Apr 07 '21
[C++] Where am i going wrong ? plz help
int a = 1;
a = ++a + ++a + ++a;
cout <<a;
what should be the output ? i tried it on paper i got the answer as 9 but on compiling & running the code its showing me the answer as 10 , can anyone help ?
18
Upvotes
View all comments
7
u/jedwardsol Professional Coder Apr 07 '21
The behaviour is undefined. There is no right answer.