ProgrammingHard
A 5 x 7 int matrix is stored in row-major order. What is the flat offset of the cell at 1-based row 3, column 4?
- A. 16
- B. 18
- C. 17
- D. 14
Correct answer: C. 17
The 0-based indices are (2, 3), so the offset is 2 x 7 + 3 = 17. Using 1-based indices directly gives the off-by-one result 18.
More C Programming questions
- On a 4 x 4 grid, a robot moves only right or down from (0,0) to (3,3) and may not enter cell (1,1). How many routes are there?
- Which parameter declaration accepts an int a[3][4] argument from main without a warning?
- On an n x n grid with n = 4, how many cells lie on at least one of the two main diagonals?
- int a[2][2] = {1, 2, 3, 4}; What is a[1][0]?
- int a[2][3]; What is sizeof(a[1]) on a platform with 4-byte int?
- How many trailing zero bits does 96 have? (96 is 1100000 in binary.)