Question discussion

What is the output of the following code snippet ?int a = 3; int b = 5;int*p = &b;int**q = &p;*q = &a;printf("%d",*p);

2882Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following code snippet ?

int a = 3; int b = 5;

int*p = &b;

int**q = &p;

*q = &a;

printf("%d",*p);

  • ASegmentation fault
  • B0XF3000H
  • C5
  • D3
Correct answer: D

Explanation

*q = &a makes p point to a, so *p prints 3.

Discussion 0

Nobody has replied yet. Start the discussion!