Question 72

What does the following C statement mean? scanf ("%4s', str);

What does the following C statement mean? scanf ("%4s', str);
  1. ARead exactly 4 charaters from console
  2. BRead maximum 4 characters from console
  3. CRead a string in multiples of 4
  4. DNone of the above
Show answerHide answer

Correct answer: (B) Read maximum 4 characters from console

Explanation

A width in %4s limits input: scanf reads at most 4 non-whitespace characters into str. It may read fewer if whitespace comes first.

From DSSSB TGT Computer Science Practice Set 1

This is question 72 of DSSSB TGT Computer Science Practice Set 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.