Multiple choice technology programming languages

What is the output of the following code snippet ?? void main() { int a = (2,4); printf("%d", a); }

  1. 2

  2. compiler error

  3. runtime error

  4. 4

  5. 0

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

The comma operator (2,4) evaluates expressions left-to-right and returns the value of the rightmost expression. Therefore, a receives the value 4, not 2 or 0.