Difficulty: Medium
Correct Answer: 2, 4, 4
Explanation:
Introduction / Context:
This question tests how Turbo C (16-bit DOS memory model) represents pointer sizes when using near, far, and huge qualifiers. Understanding declaration binding and how sizeof applies to the pointer variable (not the pointee) is essential for legacy codebases and interviews.
Given Data / Assumptions:
Concept / Approach:
In these declarations, the qualifier nearest to the identifier (ptr1/ptr2/ptr3) determines the size of that pointer variable. The qualifiers attached to inner pointer levels affect the types they point to, not the storage size of the outer pointer variable itself.
Step-by-Step Solution:
1) char huge *near *ptr1; ⇒ ptr1 is a near pointer ⇒ sizeof(ptr1) = 2.2) char huge *far ptr2; ⇒ ptr2 is a far pointer ⇒ sizeof(ptr2) = 4.3) char huge huge ptr3; ⇒ ptr3 is a huge pointer ⇒ sizeof(ptr3) = 4.4) Therefore the output is 2, 4, 4.
Verification / Alternative check:
Compile a minimal program and compare sizeof of a variable declared as near, far, and huge in Turbo C; results match the stated sizes.
Why Other Options Are Wrong:
Option A: Assumes 8-byte huge pointer; in Turbo C, huge is 4 bytes.Option C/D: Misread the binding between qualifiers and the identifier.
Common Pitfalls:
Confusing the size of the pointer variable with the size of the pointed-to type; the latter does not affect sizeof(pointer).
Final Answer:
2, 4, 4
Discussion & Comments