rayan alex
Ranch Hand
Posts: 33
1

This is how i counted.

++x uses incremented value. So first ++x = 11
next ++x increment x again. so second ++x = 12
next x++ uses the current value in the memory. so uses 12. 11 + 12 + 12 = 35

Thank you

Rameshwar Soni
Ranch Hand
Posts: 247
Since you are telling first there is ++x then there is ++x and finally x++, so the way you have written your expression is incorrect.

you will surely get the output as 35.

rayan alex
Ranch Hand
Posts: 33
1
Hi,

Thank you for your reply. But correct out put is 33. I tried to say im getting 35.
I trying to figure out why i'm not getting 33 with my calculation.

Henry Wong
author
Marshal
Posts: 21496
84
• 2
rayan alex wrote:

This is how i counted.

++x uses incremented value. So first ++x = 11
next ++x increment x again. so second ++x = 12
next x++ uses the current value in the memory. so uses 12. 11 + 12 + 12 = 35

There is no "next ++x" (ie. second pre-increment). There is a space between the two plus signs. It is not a pre-increment, it is two unary plus operators. So, the correct expressions with precedence (and associativity) applied should be...

Henry