LearnFrenzy
Sign in Take a free test

Arrays · Array Basics MCQ · Question 10

Address of m[i][j] in a 2D array (row-major) Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

For int m[R][C] starting at address B, what is the address of m[i][j]?

  • A B + (j × R + i) × sizeof(int)
  • B B + (i × C + j) × sizeof(int) Correct
  • C B + (i + j) × sizeof(int)
  • D B + i × j × sizeof(int)
Correct Answer: Option B

C stores 2D arrays row by row. Before row i there are i full rows of C elements, then j more elements in row i: offset i × C + j elements.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Popular