← 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]?
- A.To limit how many rows can be passed
- B.The compiler needs it to find m[i][j] at position i × columns + j
- C.Because C copies the whole array into the function
- 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 →