ProgrammingVery hard

char buf[10]; int n = sprintf(buf, "%5.2f", 3.14159); printf("%d", n); What is printed?

  1. A. 4
  2. B. 6
  3. C. 5
  4. D. 10

Correct answer: C. 5

The output " 3.14" is padded to width 5 and has 5 characters, which sprintf returns. The terminator is not counted.

More C Programming questions

Exams that ask this topic