ProgrammingHard

int a[2][3] with a pointer p = &a[0][0]. Which expression gives the number of elements between a[0][0] and a[1][2]?

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

Correct answer: A. 5

a[1][2] is at flat index 1 * 3 + 2 = 5 from a[0][0], so its offset from &a[0][0] is 5 elements.

More C Programming questions

Exams that ask this topic