WorksheetsC Programming Console I/O Quiz
Total questions: 20
Worksheet time: 10mins
Which of the following is NOT defined by standard C?
Basic text-based input and output
Screen control like cursor movement and colors
Functions like printf() and scanf()
getchar() and putchar()
Which function is recommended over gets() for safety when handling string input in C?
puts()
fgets()
scanf()
printf()
Why are console I/O and file I/O considered similar internally in C?
Both use the same stream-based mechanism
Both require special keywords
Both are built into the language itself
Both are used only for graphics
Which of the following tasks is outside the scope of standard C and depends on the operating system or compiler extensions?
Reading and writing files
Displaying graphics
Printing formatted text
Reading single characters
Given the following functions: printf(), scanf(), getchar(), putchar(), which category of input/output do they belong to in standard C?
Graphics I/O
Basic text-based (TTY) I/O
File I/O
Network I/O
Explain why character I/O is considered the foundation for understanding string and file input/output operations in C.
Because it deals with reading and writing one character at a time, which is the basic unit for strings and files
Because it is faster than other I/O operations
Because it only works with numbers
Because it is not supported in most compilers
In the provided example, what is the purpose of the putchar(ch) statement?
To read a character from the user
To display the same character entered by the user
To terminate the program
To clear the buffer
Given the following code snippet, what will be the output? char ch = 'B'; putchar(ch);
A
B
C
Nothing
Line buffering in the context of getchar() means:
Line buffering means input is stored in a buffer and sent to the program only after ENTER is pressed, so getchar() does not read characters immediately.
Line buffering allows getchar() to read input from files only.
Line buffering is used to speed up output operations.
Line buffering means each character is read as soon as it is typed.
Why are getchar() and putchar() considered fundamental C functions?
They are used for string manipulation
They are used for character-level I/O
They are used for file handling
They are used for memory allocation
Which of the following is a parameter for the puts() function in C?
The string to be printed
The integer to be calculated
The file to be opened
The character to be deleted
Why is puts() considered simpler and faster than printf() in C programming?
Because it does not perform format conversions and is optimized for simple string output
Because it performs format conversions
Because it can display numbers and strings
Because it uses more memory and time
In the example program, what is the output if the user enters "Spandana" as their name?
Hello, Spandana
Hello, World
Spandana, Hello
Hello, User
DoK Level 1: According to the word-meaning list, which word is defined as "A motorized vehicle"?
car
telephone
atlas
airplane
What is the main purpose of the puts() function in C?
Displays a string followed by a newline
Reads a string from the keyboard
Reads a single character from the keyboard
Compares two strings
If you want to display a floating point number with two decimal places in C, which format specifier would you use in printf()?
%.2f
%d
%c
%s
If you want to read a double value from the keyboard using scanf(), which format specifier should you use?
%lf
%f
%c
%s
Given the printf statement: printf("I like %c %s", 'C', "very much!"); What will be the output?
I like C very much!
I like %c %s
I like very much! C
I like C
Given the following C code snippet, what will be the output for num = 10? for(num = 0; num < 16; num++) printf("%o %x %X\n", num, num, num);
10 a A
12 c C
8 8 8
A 10 10
Why would you use a precision specifier in a printf statement?
To control the number of digits after the decimal for floats or the string length
To change the color of the output
To align the output to the left
To print variables in uppercase
