🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Pointers and 2D Arrays: questions with answers

15 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. For int m[3][5];, at what position (counting from 0) in memory is m[2][3]?
  2. Q2. What does this print? (code)
  3. Q3. What is int p[4];?
  4. Q4. With 4-byte ints and int m[3][4];, how many bytes apart are m and m + 1?
  5. Q5. Which function header can receive int marks[10][6]?
  6. Q6. What does this print? (code)
  7. Q7. Why is an array of pointers better than char names[100][50] for storing names of different lengths?
  8. Q8. In a malloc matrix built as int a with one malloc per row, what is the correct way to free it?
  9. Q9. What does this print? (code)
  10. Q10. Why can't you pass int m[3][4] to a parameter of type int ?
  11. Q11. What does this print? (code)
  12. Q12. What does this print? (code)
  13. Q13. For int m[3][4];, what is m[1]?
  14. Q14. Why must a function parameter for a 2D array give the number of columns, as in int m[][6]?
  15. Q15. A matrix is stored in one malloc block of rows × cols ints, int a. How do you reach row i, column j?