🎙 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 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 **?

  1. A.int ** is only for strings
  2. B.A 2D array is one block of ints, but int ** expects an array of separate pointers, so the types do not match
  3. C.Functions cannot take 2D arrays at all
  4. 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 →