← Quiz: Pointers and 2D Arrays: all 15 questions
Quiz: Pointers and 2D Arrays · Question 10 of 15
Why can't you pass int m[3][4] to a parameter of type int ?
Why can't you pass int m[3][4] to a parameter of type int **?
- A.int ** is only for strings
- B.A 2D array is one block of ints, but int ** expects an array of separate pointers, so the types do not match
- C.Functions cannot take 2D arrays at all
- D.It works, but only if the array is global
Answer & explanation
Correct answer: A 2D array is one block of ints, but int ** expects an array of separate pointers, so the types do not match
m decays to int (*)[4], a pointer to a row. Treating the int values as addresses would be wrong.
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 →