edited by
8,680 views
1 votes
1 votes
void fun(int *p) 

{

int q = 10;

p = &q;

}

int main()

{

int r = 20;

int *p = &r;

fun(p);

printf("%d", *p);

return 0;

}

 

edited by

1 Answer

Best answer
8 votes
8 votes

The answer is 20.

because the pointer p in main and pointer p in function are different having different addresses... the p in function is local to the func()

you can refer this:-

selected by

Related questions

2 votes
2 votes
1 answer
1
1 votes
1 votes
1 answer
3
Desert_Warrior asked May 15, 2016
2,587 views
main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }
1 votes
1 votes
1 answer
4
Na462 asked Jan 8, 2019
1,400 views
#include <stdio.h>main (){unsigned x = -10;int X = 20;if (X x) printf ("Hello");else{ printf ("%d",x); printf ("Jello"); }}