wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C++ Input/Output Quiz

Total questions: 22

Worksheet time: 11mins

Name
Class
Date
1.

Which header file is needed to use cin and cout?

a)

stdio.h

b)

iostream

c)

conio.h

d)

cstdlib

2.

What does cout stand for?

a)

Console Output

b)

Character Out

c)

Current Output

d)

Compiler Output

3.

Which operator is used with cout?

a)

>>

b)

>

c)

> "Hello World";

d)

cout > x;

4.

What is inserted by endl in C++ output?

a)

Space

b)

Newline

c)

Tab

d)

Nothing

5.

Which of the following outputs a newline?

a)

cout > num;

b)

cout >> num;

c)

cout > a, b;

d)

cin >> a >> b;

6.

What is the output of: cout > str;

a)

cin.getline(str, 100);

b)

getline(cin, str);

c)

All of the above

7.

Which one reads a line including spaces into a string variable?

a)

cin >> str;

b)

getline(cin, str);

c)

cin.get(str);

d)

cin.str();

8.

cout belongs to which class?

a)

ios

b)

ostream

c)

istream

d)

iostream

9.

cin belongs to which class?

a)

ios

b)

ostream

c)

istream

d)

iostream

10.

Which is correct to print tab between two numbers?

a)

cout >

b)

=

c)

*

11.

What will happen if wrong type is entered for cin?

a)

Program stops

b)

cin goes into fail state

c)

Value auto-converts

d)

Compiler error

12.

Which function resets cin after failure?

a)

cin.fail()

b)

cin.clear()

c)

cin.reset()

d)

cin.flush()

13.

What does cin.ignore() do?

a)

Ignores one character

b)

Ignores entire line

c)

Ignores whitespace

d)

Ignores errors

14.

What is the output of: cout > c;

a)

char c; cin.get(c);

b)

Both A and B

c)

None

15.

What is default base for cout numbers?

a)

Decimal

b)

Binary

c)

Octal

d)

Hex

16.

Which manipulator sets number base to hex?

a)

sethex()

b)

hex

c)

base(16)

d)

HEX

17.

Which manipulator sets number base to octal?

a)

oct

b)

setoct()

c)

base(8)

d)

eight

18.

Which manipulator restores base to decimal?

a)

dec

b)

setdec()

c)

base(10)

d)

reset

19.

Which keyword is needed for using cin and cout?

a)

class

b)

std

c)

using namespace std;

d)

Both B and C

20.

Which of the following prints "100%" correctly?

a)

cout << "100%";

b)

cout << 100%;

c)

cout << "100%%";

d)

cout << 100 << %;

21.

Which is the correct input/output type in C++?

a)

Stream-based

b)

Function-based

c)

Macro-based

d)

File-based only

22.

What is the correct file extension for standard C++ source?

a)

.c

b)

.cpp

c)

.h

d)

.exe