1 2 3 4 5 6 7 8 9 10 11 | #include<stdio.h> void f(int *p,int *q){ p=q; *p=2; } int i=0,j=1; int main(){ f(&i,&j); printf("%d %d\n",i,j); return 0; } |
(A) 2 2 (B) 2 1 (C) 0 1 (D) 0 2
Explaination :
In main function we are passing the address of i and j in function f()
and collecting the addresses in pointer variable p and q respectively.
Now we are assigning the content of q to the p
So *p=2 will change value at address 650008.
so the value of j is now 2.
and value of i is not changed.
So the output is 0 2