LearnFrenzy
Sign in Take a free test

C Input / Output · Input/Output MCQ · Question 1

What does scanf() return in C? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

What does scanf() return?

  • A The number of characters read
  • B The number of input items successfully assigned, or EOF if input ends first Correct
  • C Always 0 on success
  • D The last value read
Correct Answer: Option B

Comparing the return value with the expected count (scanf("%d %d", &a, &b) == 2) is the standard way to validate input.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links