Difficulty: Easy
Correct Answer: i= FFE4 ptr=10 j=FFE2 ptr=20
Explanation:
Introduction / Context:A pointer-to-const (const int *) allows reading the pointed value but not modifying it. Reassigning the pointer itself to point to a different object is legal because the pointer is not const-qualified here. The program prints the address held in the pointer (using a hex-like format) and then the value obtained by dereferencing it, first for i and then after reassigning to j. While exact addresses vary, the pattern of printing the current address and associated value is predictable.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Initialize ptr to &i → dereference prints 10 after showing some address.Reassign ptr to &j → dereference prints 20 after showing the new address.Among the options, only one displays values 10 and 20 in that order, paired with plausible hex addresses.Verification / Alternative check:
Running analogous code on Turbo C typically yields two distinct near-pointer values and the expected integers. Modern compilers require using %p to print pointers portably.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
i= FFE4 ptr=10 j=FFE2 ptr=20
Discussion & Comments