ProgrammingVery hardProduct company OA

What is printed?

What is printed?
int a[] = {10, 20, 30};
printf("%d", a[1, 2]);
  1. A. 30
  2. B. 10
  3. C. 20
  4. D. Compilation error: a is not two-dimensional

Correct answer: A. 30

In C the subscript is a single expression, and 1, 2 is a comma expression whose value is 2. So a[1, 2] is a[2] = 30. (C++20 deprecated this use of the comma in subscripts; C still allows it.)

More C Programming questions

Exams that ask this topic