ProgrammingHardProduct company OA

What is printed?

What is printed?
int a[3][3] = {{1}, {2, 3}, [2][1] = 7};
printf("%d %d %d %d", a[0][1], a[1][1], a[2][0], a[2][1]);
  1. A. 0 3 0 7
  2. B. 0 0 0 7
  3. C. 2 3 0 7
  4. D. 0 3 7 0

Correct answer: A. 0 3 0 7

Each inner brace initialises one row and zero-fills the rest of it: row 0 is 1 0 0 and row 1 is 2 3 0. The designator [2][1] sets that single element to 7, and everything not mentioned is 0.

More C Programming questions

Exams that ask this topic