ProgrammingVery hardGATE CS · Campus placements

int a[2][3] = {{1, 2, 3}, {4, 5, 6}}; int *p = &a[0][0]; printf("%d", p[4]); What is printed?

  1. A. 4
  2. B. 5
  3. C. 6
  4. D. 2

Correct answer: B. 5

Rows are stored contiguously, so p[4] is element a[1][1], which is 5. Indexing a 2D array through a flat pointer is valid when the index stays in range.

More C Programming questions

Exams that ask this topic