← Quiz: C Pointers: all 10 questions
Quiz: C Pointers · Question 8 of 10
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
int a[] = {5, 6, 7};
int *p = a;
int x = *p++;
printf("%d %d\n", x, *p);
return 0;
}
- A.6 6
- B.6 7
- C.5 6
- D.5 5
Answer & explanation
Correct answer: 5 6
*p++ reads the value at p (5) and then moves p to the next element, which holds 6.
Can you get the rest right without peeking?
Take the timed Quiz: C Pointers quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →