Difficulty: Medium
Correct Answer: 2, 4, 4
Explanation:
Introduction / Context:
In 16-bit DOS memory models, pointer types can differ in size depending on near/far/huge qualifiers. Turbo C commonly uses 16-bit near pointers by default and 32-bit far/huge pointers. Understanding this is vital for legacy code and memory model portability.
Given Data / Assumptions:
Concept / Approach:
sizeof(pointer) yields the storage size of the pointer value, not the memory block it points to. Under 16-bit compilers: near = 2 bytes, far = 4 bytes, huge = 4 bytes. Hence the output “2, 4, 4”.
Step-by-Step Solution:
Evaluate sizeof(s1) → 2.Evaluate sizeof(s2) → 4.Evaluate sizeof(s3) → 4.Print “2, 4, 4”.
Verification / Alternative check:
Switching memory models in project options can change the default pointer size, but explicitly qualified far/huge remain 4 bytes; near remains 2 bytes.
Why Other Options Are Wrong:
A/E suggest 6-byte pointers, which Turbo C does not use. B/D misstate sizes for the qualifiers.
Common Pitfalls:
Confusing pointer size with addressable memory; assuming modern 32/64-bit behavior applies to 16-bit environments.
Final Answer:
2, 4, 4
Discussion & Comments