1,208 views
1 votes
1 votes
#include <stdio.h>
void f(int x,int *p)
{
    *p=x;
    x=10;
}
int main()
{
    int a=5,b=6;
    int *p=&a,**q;
    *p=20;
    q=&p;
    f(a,&b);
    *q=&b;
    *p=30;
    printf("%d",b);
}

How the answer is 30 I am getting 20?

1 Answer

Best answer
4 votes
4 votes
See  last 3 lines of main() function

 

q is pointing to p

*q = &b implies that now p is pointing to b

*p= 30

Implies contents of variable b now modified to 30
selected by

Related questions

0 votes
0 votes
0 answers
1
Na462 asked Aug 22, 2018
480 views
What will be output ?A. Abnormal Termination.B. Infinite loopC. Output wil be 65536D. NoneAns. D
0 votes
0 votes
1 answer
2
srestha asked Feb 4, 2017
474 views
What will be output?