C | Input and Output | Question 9
What does the following C statement mean?
scanf("%4s", str); |
chevron_right
filter_none
(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;
}
Recommended Posts:
- C | Input and Output | Question 13
- C | Input and Output | Question 8
- C | Input and Output | Question 11
- C | Input and Output | Question 13
- C | Input and Output | Question 6
- C | Input and Output | Question 13
- C | Input and Output | Question 5
- C | Input and Output | Question 4
- C | Input and Output | Question 13
- C | Input and Output | Question 12
- C | Input and Output | Question 3
- C | Input and Output | Question 2
- Basic Input and Output in C
- Input-output system calls in C | Create, Open, Close, Read, Write
- Output of C programs | Set 63



