ProgrammingHardProduct company OA

What value does this call to printf return?

What value does this call to printf return?
printf("%5.1f|%-5d|", 3.14159, 42);
  1. A. 14
  2. B. 10
  3. C. 12
  4. D. 9

Correct answer: C. 12

%5.1f prints " 3.1" (width 5), %-5d prints "42 " (left-justified, width 5), and there are two '|' characters: 5 + 1 + 5 + 1 = 12. printf returns the number of characters written.

More C Programming questions

Exams that ask this topic