Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Console I/O Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following is NOT defined by standard C?

a)

Basic text-based input and output

b)

Screen control like cursor movement and colors

c)

Functions like printf() and scanf()

d)

getchar() and putchar()

2.

Which function is recommended over gets() for safety when handling string input in C?

a)

puts()

b)

fgets()

c)

scanf()

d)

printf()

3.

Why are console I/O and file I/O considered similar internally in C?

a)

Both use the same stream-based mechanism

b)

Both require special keywords

c)

Both are built into the language itself

d)

Both are used only for graphics

4.

Which of the following tasks is outside the scope of standard C and depends on the operating system or compiler extensions?

a)

Reading and writing files

b)

Displaying graphics

c)

Printing formatted text

d)

Reading single characters

5.

Given the following functions: printf(), scanf(), getchar(), putchar(), which category of input/output do they belong to in standard C?

a)

Graphics I/O

b)

Basic text-based (TTY) I/O

c)

File I/O

d)

Network I/O

6.

Explain why character I/O is considered the foundation for understanding string and file input/output operations in C.

a)

Because it deals with reading and writing one character at a time, which is the basic unit for strings and files

b)

Because it is faster than other I/O operations

c)

Because it only works with numbers

d)

Because it is not supported in most compilers

7.

In the provided example, what is the purpose of the putchar(ch) statement?

a)

To read a character from the user

b)

To display the same character entered by the user

c)

To terminate the program

d)

To clear the buffer

8.

Given the following code snippet, what will be the output? char ch = 'B'; putchar(ch);

a)

A

b)

B

c)

C

d)

Nothing

9.

Line buffering in the context of getchar() means:

a)

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.

b)

Line buffering allows getchar() to read input from files only.

c)

Line buffering is used to speed up output operations.

d)

Line buffering means each character is read as soon as it is typed.

10.

Why are getchar() and putchar() considered fundamental C functions?

a)

They are used for string manipulation

b)

They are used for character-level I/O

c)

They are used for file handling

d)

They are used for memory allocation

11.

Which of the following is a parameter for the puts() function in C?

a)

The string to be printed

b)

The integer to be calculated

c)

The file to be opened

d)

The character to be deleted

12.

Why is puts() considered simpler and faster than printf() in C programming?

a)

Because it does not perform format conversions and is optimized for simple string output

b)

Because it performs format conversions

c)

Because it can display numbers and strings

d)

Because it uses more memory and time

13.

In the example program, what is the output if the user enters "Spandana" as their name?

a)

Hello, Spandana

b)

Hello, World

c)

Spandana, Hello

d)

Hello, User

14.

DoK Level 1: According to the word-meaning list, which word is defined as "A motorized vehicle"?

a)

car

b)

telephone

c)

atlas

d)

airplane

15.

What is the main purpose of the puts() function in C?

a)

Displays a string followed by a newline

b)

Reads a string from the keyboard

c)

Reads a single character from the keyboard

d)

Compares two strings

16.

If you want to display a floating point number with two decimal places in C, which format specifier would you use in printf()?

a)

%.2f

b)

%d

c)

%c

d)

%s

17.

If you want to read a double value from the keyboard using scanf(), which format specifier should you use?

a)

%lf

b)

%f

c)

%c

d)

%s

18.

Given the printf statement: printf("I like %c %s", 'C', "very much!"); What will be the output?

a)

I like C very much!

b)

I like %c %s

c)

I like very much! C

d)

I like C

19.

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);

a)

10 a A

b)

12 c C

c)

8 8 8

d)

A 10 10

20.

Why would you use a precision specifier in a printf statement?

a)

To control the number of digits after the decimal for floats or the string length

b)

To change the color of the output

c)

To align the output to the left

d)

To print variables in uppercase