Don Yazurlo wrote:So, how would you read ths code? First, the x is incremented and returned to the expression, which is multiplied by 5, We can simplify this:
int y = 4 * 5 / x-- + --x;
I believe that either the table is incorrect or the first step in resolving the expression would've been to substitute the three for the x--
y = ++x * 5 / 3 + --x;
No, where you typed in 3, there really supposed to be 4 as there is used post-decrement, meaning, you place current value into expression and only then decrement.
So the whole expression evaluates next:
int x = 3;
int y = ++x * 5 / x-- + --x;
int y = 4 * 5 / 4 + 2;
y = 20 / 4 + 2;
y = 5 + 2;
y = 7;
x = 2;