0
can any one explain me output of this
int a=5; cout <<++a+a++;
3 Answers
+ 2
2 cout<<++a+a++;
Strings in code compile from right side to left.
Order:
1)cout<<++a+(a++); //a = 5
a will be incremented after this string.
2)cout<<(++a)+a; //a = 6
a is incrementing now.
3)cout<<a+a; //a = 6
cout << 6+6;
Result is 12.
After string #2 a will be equal 7.
+ 1
the output of the code will be 12
0
Just start from the left side. The first ++ say increment a by 1. So you have a=6 and cout<<a+a++; Next add a and a. So you have a=6+6=12 and cout << a++; The value of a is printed on screen (12) and then, becose of the last ++ a is incremented by 1, so a = 13.



