Multiple choice

What would be the output of the following?

void main() { int z,x=5,y=-10,a=4,b=2; z=x++ - --y *b/a; printf("%d",z); }

  1. 5

  2. 12

  3. 10

  4. 11

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

Evaluating z = x++ - --y * b / a with x=5, y=-10, a=4, b=2: --y makes y=-11, so the expression is 5 - (-11 * 2 / 4) = 5 - (-22 / 4) = 5 - (-5) = 10. Note: integer division -22/4 = -5 (truncated toward zero). x++ is post-increment, so 5 is used.