ProgrammingVery hard

For an int matrix a with R rows and C columns stored in row-major order, what is the flat index of the cell at (r, c) in terms of R?

  1. A. The index is r * C + c, and R does not enter the formula
  2. B. r * R + c
  3. C. r + c * R
  4. D. c * C + r

Correct answer: A. The index is r * C + c, and R does not enter the formula

The number of rows does not change where a row starts. Row r starts after r rows of C elements each.

More C Programming questions

Exams that ask this topic