ProgrammingModerateProduct-company MCQ pattern

What is printed?

What is printed?
int a = (1, 2, 3);
int b = 5;
b = (b + 1, b * 2);
printf("%d %d", a, b);
  1. A. 1 10
  2. B. 3 6
  3. C. 3 10
  4. D. 1 6

Correct answer: C. 3 10

The comma operator evaluates its left operand, discards it, and yields the right operand: (1, 2, 3) is 3 and (b + 1, b * 2) is 10. b + 1 does not modify b. Without the parentheses, int a = 1, 2, 3; would not compile.

More C Programming questions

Exams that ask this topic