+ 1

what is output of x += x +=x++ ;

int x ; x=0; x += x +=x++ ; cout << x ; and why ??

24th Sep 2017, 11:08 AM
Kingooo
Kingooo - avatar
2 Réponses
+ 4
Given x starts as an uninitialized random value, it could be anything. If you initialize it to zero on declaration, it should work, but I tried to run it and got 'compilation error' as my output. What I expected to happen is: int x = 0; x++; // 1 x += x; // 2 for right assignment x += x; // 4 for left assignment
24th Sep 2017, 11:28 AM
John Wells
John Wells - avatar