Difficulty: Medium
Correct Answer: 1990
Explanation:
Introduction / Context:
This question targets legacy 16-bit DOS Turbo C behavior where compiler-provided register variables (such as _AX) can be used to specify a function’s return value directly. It assesses platform-specific calling conventions and how return values are passed.
Given Data / Assumptions:
Concept / Approach:
Many 16-bit compilers map function return values to specific CPU registers. For an int, Turbo C returns via AX. Writing to _AX (a compiler extension naming the register) before the function exits sets the return value exactly as if the function had executed return 1990;.
Step-by-Step Solution:
Call fun().Inside fun, assign _AX = 1990.Function returns; caller receives AX content as the integer result.Prints 1990.
Verification / Alternative check:
Replacing _AX = 1990; with return 1990; is portable and yields the same output. The register assignment method is non-portable and specific to Turbo C.
Why Other Options Are Wrong:
“Garbage value” or “0” would occur only if the convention were different or the code uninitialized the register, which is not the case here. “No output” is incorrect; printf executes.
Common Pitfalls:
Attempting to use _AX on modern compilers where it is undefined; assuming this trick is portable across architectures or compilers.
Final Answer:
1990
Discussion & Comments