0
Output of this small program is 9. How?
2 Answers
+ 2
Ayush Singh you might want to take a look at the lessons explaining "unary operators" again.
When you use "++x", this happens...
x=x+1;
It's value increments by 1 and gets "stored".
Thus, the first time u did ++x it became 4, the second time it became 5. Therefore, 4+5. Which is 9.
+ 4
int z = ++x; // z = 5 not 4