Multiple choice

Consider the following function: void f(unsigned int n) { do { putchar ('0' + (n % 10)) ; } while (n /= 10) ; putchar (' n') ; }

What is the output of f(837)?

  1. 387

  2. 738

  3. 800

  4. 700

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The function prints digits in reverse order. It repeatedly extracts the last digit using n % 10 (7, then 3, then 8 for 837) and divides n by 10. The do-while ensures at least one iteration. So f(837) prints '738' followed by newline. Option A is in reverse order, C and D are incorrect values.