Multiple choice technology programming languages

What will be the output of the following program : void main() { int a=1,b=2,c=3; c=(--a, b++)-c; printf("%d %d %d",a,b,c); }

  1. 0 3 -3

  2. Compile-Time Error

  3. 0 3 -1

  4. 0 3 0

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

The expression uses the comma operator which evaluates left operand and returns right operand. --a is prefix decrement so a becomes 0. b++ is postfix increment so b returns 2 then becomes 3. The comma expression (--a, b++) returns 2. Then c = 2 - 3 = -1. Output: a=0, b=3, c=-1. Option A is wrong (c=-3 incorrect). Option D is wrong (c=0 incorrect).