The Wayback Machine - https://web.archive.org/web/20240205185241/https://www.geeksforgeeks.org/c-input-and-output-question-9/
Open In App
Related Articles

C | Input and Output | Question 9

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

What does the following C statement mean? 
 

C




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
Please comment below if you find anything wrong in the above post

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads