🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Pointers and 2D Arrays: all 15 questions

Quiz: Pointers and 2D Arrays · Question 14 of 15

Why must a function parameter for a 2D array give the number of columns, as in int m[][6]?

Why must a function parameter for a 2D array give the number of columns, as in int m[][6]?

  1. A.To limit how many rows can be passed
  2. B.The compiler needs it to find m[i][j] at position i × columns + j
  3. C.Because C copies the whole array into the function
  4. D.It is only a comment for the reader
Answer & explanation

Correct answer: The compiler needs it to find m[i][j] at position i × columns + j

Without the row length, the compiler cannot work out where each row starts.

Can you get the rest right without peeking?

Take the timed Quiz: Pointers and 2D Arrays quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →