0

Output of this small program is 9. How?

https://code.sololearn.com/c49e664iF1uc/?ref=app

14th Oct 2022, 7:39 AM
Ayush Singh
Ayush Singh - avatar
2 Antworten
+ 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.
14th Oct 2022, 10:31 AM
Bhaveshsingh Pawar
Bhaveshsingh Pawar - avatar
+ 4
int z = ++x; // z = 5 not 4
14th Oct 2022, 7:42 AM
SoloProg
SoloProg - avatar