Difficulty: Medium
Correct Answer: 4, 2, 2
Explanation:
Introduction / Context:
sizeof can be applied either to a pointer variable or, after dereferencing, to another pointer type. This question mixes multi-level pointers with near/far/huge and asks you to resolve sizes under Turbo C (16-bit DOS).
Given Data / Assumptions:
Concept / Approach:
Unroll types stepwise. Each * removes one indirection level and exposes the next pointer's qualifier, which determines sizeof at that level.
Step-by-Step Solution:
1) sizeof(ptr1): ptr1 is far * ⇒ 4.2) sizeof(**ptr2): *ptr2 is a far *; **ptr2 is a near * ⇒ 2.3) sizeof(ptr3): ptr3 is near * ⇒ 2.4) Hence: 4, 2, 2.
Verification / Alternative check:
Print sizeof of each intermediate type in a separate test to see 4 (far *) and 2 (near *).
Why Other Options Are Wrong:
Option A: Treats all three as 4-byte pointers.Option C/D: Introduce impossible 8-byte sizes or wrong bindings.
Common Pitfalls:
Assuming dereferencing always yields a char rather than a pointer type at the next level; here **ptr2 still yields a pointer (near *).
Final Answer:
4, 2, 2
Discussion & Comments