What value is printed by the following C program?

#include <stdio.h>
int main(void)
{
    int x = 25;
    int *p = &x;
    int **q = &p;
    printf("%d", **q);
    return 0;
}
                        

Options

  • A. Address of x
  • B. Address stored in p
  • C. 25
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. 25

Detailed Explanation

Correct Answer: Option C

Explanation:
q points to p, and p points to x. The expression *q gives p, while **q gives the value of x. Therefore, the output is 25.