ProgrammingHard

A recursive function prints a list after its recursive call returns, as in print(n) { if (!n) return; print(n->next); putchar(n->v + '0'); }. For the list 1 -> 2 -> 3, what is printed?

  1. A. 123
  2. B. 13
  3. C. 321
  4. D. 312

Correct answer: C. 321

The recursion goes to the end before printing, so each node prints on the way back up, giving the reverse order.

More C Programming questions

Exams that ask this topic