ProgrammingModerate

A matrix has R rows and C columns with R = 3 and C = 4 in a flat array of 12 ints. What flat index is cell (2, 3)?

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

Correct answer: B. 11

Row-major offset is row * C + col = 2 * 4 + 3 = 11, the last cell of the 12-int array. 9 multiplies by R instead of C, 6 treats the indices as 1-based, and 5 forgets the row stride entirely.

More C Programming questions

Exams that ask this topic