I came across this problem in this website, and tried it in Eclipse but couldn\'t understand how exactly they are evaluated.
int x = 3, y = 7, z = 4;
The postfix operator x++
means something like "give me the value of x now, but increment it for future references"
So, by the order of operations and evaluation,
x++ * x++ * x++
is interpreted first as
3 * 4 * 5
(=60)
Which is then added to the original 3, yielding 63.
The original value is used because it's on the same line, had you written something like:
int x = 3;
int y += x++ * x++ * x++;
x += y;
x
would now be 66, instead of 63 because the x
in the second line is now 6, rather than its original 3.