Similar questions 2 more →
Recursion

Answer & solution
Official answer: C
Approach: Distinguish the order in which recursive calls read characters from the order in which suspended calls resume printing.
1. The first call stores '1' in its own local a and calls fX again before reaching putchar. The next calls similarly store '2', '3' and '4'. Each call has a separate local variable.
2. A fifth call reads the newline. Both conditions are false, so this call neither recurses nor prints and returns immediately.
3. The suspended call holding '4' now continues at its second condition and prints 4. Returning again prints 3, then 2, then 1.
4. Once the first call returns, main terminates. The newline itself is never printed.
Answer: C, output 4321. Printing before the recursive call would preserve input order; printing after it reverses order. The explicitly supplied newline is the stopping condition, so no assumption about reading past end-of-file is needed.
The printed program uses typographic single quotation marks. Taken literally these are not valid C delimiters, so the program does not compile as printed. The answer above follows the intended textbook interpretation with ASCII quote delimiters.