+ 1
How does it work?
int a=4,b; b=a+ ++a; cout <<b; the result is 10 How does it work??? what is the logic???
4 ответов
+ 1
I suppose you don't understand why
a + ++a = 10
Here the second 'a' is incremented before anything because of the pre-increment operator.
So a=5. Then, once the '++' is executed, we have a+a with a=5. 5+5=10.
Ask if you don't understand
+ 3
starting from right => ++a = 4+1=5, b = a + 5 => 5 + 5 = 10
+ 1
thank you for help!!!!
- 1
You're welcome :)