1. Home
  2. Computer Science MCQs
  3. C Programming
  4. What does printf return when it succeeds?

Added 30 Nov -0001

What does printf return when it succeeds?

  1. The number of format specifiers in the format string
  2. EOF, matching the convention used by getchar
  3. The number of characters transmitted to the output stream Correct answer
  4. Zero on success and a negative value on failure only

Correct answer

C. The number of characters transmitted to the output stream

15 views

MCQSEXAM

Explanation

printf returns the count of characters written, or a negative value if an output or encoding error occurs, which lets callers detect partial writes. Because the value counts characters rather than items, it doubles as a quick measure of formatted output length. puts differs by appending a newline and returning a non-negative value on success.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C Programming MCQs

Practise all C Programming MCQs

Similar MCQs