Similar questions 5 more →
Pointers & Memory

Your answer
Answer & solution
Answer: D (no official key was published)
Initially i=0 and j=1. The local parameter assignment p=q redirects p to j, without altering i or the caller’s pointer arguments. Then *p=2 writes j=2. The printed values are 0 2, option D.
C passes the pointer values by value. At entry p contains &i and q contains &j; p=q copies &j into the local pointer p. It does not copy j into i. The later dereference acts on the new pointee j. Distinguish p=q, which redirects a pointer, from *p=*q, which would copy an integer.