← Quiz: Pointers and 2D Arrays: all 15 questions
Quiz: Pointers and 2D Arrays · Question 9 of 15
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
int m[3][2] = {{1, 2}, {3, 4}, {5, 6}};
int (*r)[2] = m;
r += 2;
printf("%d", r[0][1]);
return 0;
}
- A.2
- B.3
- C.4
- D.6
Answer & explanation
Correct answer: 6
r points to rows; r += 2 moves to row 2 = {5, 6}, and r[0][1] is 6.
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 →