Skip to content
Related Articles

Related Articles

C | Input and Output | Question 9
  • Difficulty Level : Easy
  • Last Updated : 29 Aug, 2013

What does the following C statement mean?




scanf("%4s", str);

(A) Read exactly 4 characters from console.
(B) Read maximum 4 characters from console.
(C) Read a string str in multiples of 4
(D) Nothing


Answer: (B)

Explanation: Try following program, enter GeeksQuiz, the output would be “Geek”

#include <stdio.h>

int main()
{
    char str[50] = {0};
    scanf("%4s", str);
    printf(str);
    getchar();
    return 0;
}


Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :