Difficulty: Easy
Correct Answer: Prints "CuriousTab"
Explanation:
Introduction / Context:
This C program checks your understanding of control flow, short-circuit termination using exit, and what happens to code that appears after exit. Although the code includes a recursive call to main, the presence of exit(1) changes the practical behavior and prevents recursion from executing.
Given Data / Assumptions:
Concept / Approach:
Key ideas are: local automatic storage duration (i resets to 0 for each fresh call to main), condition evaluation (i becomes 1, so i <= 5 is true), and the semantics of exit which ends the program immediately. Any statements after exit, including the recursive main(), are unreachable at runtime.
Step-by-Step Solution:
Start main: i = 0.Increment: i++ makes i = 1.Condition i <= 5 is true → enter if block.printf outputs the string: CuriousTab.exit(1) terminates the program instantly; the subsequent main() call never executes.
Verification / Alternative check:
Compile and run: you will see one occurrence of the word CuriousTab (no newline). Adding a fflush(stdout) is unnecessary here because exit performs normal program termination and flushes stdout for line-buffered/fully buffered streams connected to terminal or files.
Why Other Options Are Wrong:
Prints "CuriousTab" 5 times: would require loop/recursion to continue; exit prevents this.Function main() does not call itself: the call is present syntactically, but it is never reached.Infinite loop: program terminates via exit.Compilation error due to recursion: calling main is permitted by the standard, though usually discouraged.
Common Pitfalls:
Assuming exit returns; believing local i persists across calls; expecting recursion to proceed before process termination.
Final Answer:
Prints "CuriousTab"
Discussion & Comments