See annotations:
#include <stdio.h>
void f(int *p, int *q) // p contains address of i, q contains address of j
{
p=q; // p now contains address of j
*p=2; // assigns 2 to j, not i
}
int main()
{
int i=0,j=1; // i contains 0, j contains 1
f( &i, &j ); // call f with pointers to i and j
printf( "%d%d\n", i, j ); // after call to f, i is unchanged, j contains 2
return 0;
}
Output will be 02, not 21 or 22. The answer sheet you’re referring to is incorrect.
Edit
It’s a sad fact of life that many of the people teaching C programming don’t know the language that well.
solved What is the output of the program with reason?