ProgrammingVery hardProduct company OA

What is printed?

What is printed?
int a[] = {10, 20, 30, 40, 50};
printf("%d", a[1, 3]);
  1. A. 20
  2. B. Compilation error
  3. C. Garbage value
  4. D. 40

Correct answer: D. 40

Inside [] the comma is the comma operator (not an argument separator), which evaluates 1, discards it, and yields 3. So a[1, 3] is a[3] = 40.

More C Programming questions

Exams that ask this topic