ProgrammingVery hardCompetitive coding (CP)

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    int x = 0, *p = &x;
    *p++ = 5;
    printf("%d", x);
}
  1. A. 0
  2. B. 1
  3. C. 6
  4. D. 5

Correct answer: D. 5

*p++ assigns 5 through the old value of p, which points at x, and then p moves one past x without being dereferenced. So x becomes 5.

More C Programming questions

Exams that ask this topic