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