1. Trouble finding correct value

Hey all, I know this is a newb question here but I'm having trouble finding the answer to this equation posed in one of my past year exam scripts.

Code:
```int z, x = 5, y = -10, a = 4, b = 2;
//x = 5
//y = -10
//a = 4
//b = 2

z = x++ - --y * b / a;```
When I solve this equation I get an answer of 0 (zero) but when I put it in the compiler, the value returned is 10.

Heres how I solved it:

z = x++ - (--y) * b / a;
z = 5++ - (--(-10)) * 2 / 4;
z = 6 - (-11) * 2 / 4;
z = 6 - (-11) * 0 // at this point 2/4 yields 0 correct?
z = 6 + 11 * 0
z = 0;
but I am sadly mistaken as the answer is 10 according to the compiler.
Can any one help me out here?
Please and thank you. Any feedback is greatly appreciated.

2. x++
This increments x after the expression is evaluated.
--y * b / a;
Y is decremented first, then multiplication and division are done in one go, left to right.

z = 6 + 11 * 0
z = 0;
ORDER OF OPERATIONS!!!

Ten is what I got, btw.

3. Originally Posted by bernt
This increments x after the expression is evaluated.

Y is decremented first, then multiplication and division are done in one go, left to right.

ORDER OF OPERATIONS!!!

Ten is what I got, btw.
Thank you thank you, I finally got 10.

x++ - --y * b / a;
5 - (-11) * 2 / 4;
5 - (-22)/4
5 - (-5)
= 5 + 5 = 10.

4. Code:
`z = 5++ - (--(-10)) * 2 / 4;`
That is not a legal C++ statement.

5. Originally Posted by Memloop
Code:
`z = 5++ - (--(-10)) * 2 / 4;`
That is not a legal C++ statement.
I just wrote that to denote the brackets, to help visualise that (-10) would have been decremented.