ProgrammingHard

int a[2][3] = {{7, 8, 9}, {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

a[2][3] is stored row after row, so p[4] is flat index 4 = 1 * 3 + 1, i.e. a[1][1] = 5. 4 is p[3] (a[1][0]), the off-by-one slip, and 6 is a[1][2].

More C Programming questions

Exams that ask this topic