Multiple choice

int z,x=5,y=-10,a=4,b=2; z = x++ - --y * b / a; What will be the value of z in the sample code given above?

  1. 5

  2. 6

  3. 10

  4. 11

  5. 12

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

First calculate --y = -11 (pre-decrement), then x++ uses 5 (post-increment, x becomes 6 after). The expression --y * b / a = -11 * 2 / 4 = -22 / 4 = -5 (integer division). So z = 5 - (-5) = 10. Remember operator precedence: postfix ++ has highest precedence, then prefix --, then *, /, then +, -.