🎙 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 11 of 15

What does this print? (code)

What does this print?

#include <stdio.h>
int main(void) {
    int m[2][3] = {{1, 2, 3}, {4, 5, 6}};
    int *p = &m[0][0];
    printf("%d %d\n", *(p + 4), *(*(m + 1) + 2));
    return 0;
}
  1. A.4 5
  2. B.5 6
  3. C.5 3
  4. D.2 6
Answer & explanation

Correct answer: 5 6

The values are stored row by row, so position 4 is 5; ((m + 1) + 2) is m[1][2], which 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 →