+ 2

int main() {int i=4; i=++i-i++ +(2*i); if(i>10) i=i+(--i); cout<<i;

please explain the working

23rd Oct 2017, 7:34 AM
suhail pgm
suhail pgm - avatar
2 Answers
+ 5
i=4 next 5-5 in the next + (2*6 )because increments i =6 and first do it multiplication and later add and result is 12. 12 > 10. i=i +(--i); i=12+11; output 23. If I'm wrong I'll be greatful for improve.
23rd Oct 2017, 8:21 AM
Andrew
Andrew - avatar
+ 3
I think at the first equation, i becomes 5-5 + (2*5). So 10. After that i gets incremented because of i++. So it becomes 11. After that i becomes 10-10 = 0. I did this in my head, I might be wrong. What's the output?
23rd Oct 2017, 7:41 AM
Mert Açıkportalı
Mert Açıkportalı - avatar