LearnFrenzy
Sign in Take a free test

Pointers · Predict the Output · Question 8

Pointer to pointer (**pp) output in C Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

What is the output of the following C program?

main.c
#include <stdio.h>

int main(void) {
    int x = 5;
    int *p = &x;
    int **pp = &p;
    **pp = 50;
    printf("%d %d %d\n", x, *p, **pp);
    return 0;
}
  • A 5 5 50
  • B 5 50 50
  • C 50 50 50 Correct
  • D Compilation error
Correct Answer: Option C

pp points to p, and p points to x. **pp follows both arrows and lands on x, so x becomes 50. All three expressions read x.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Popular