wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SET A

Total questions: 10

Worksheet time: 2mins

Name
Class
Date
1.
  1. 1. What is the purpose of the #include <iostream> directive in a C++ program? 

a)

a) To define a variable

b)

b) To include input/output functionality

c)

c) To create a new namespace

d)

d) To declare a function

2.
  1. 2. What does the cout object do in C++? 

a)

a) Reads input from the user

b)

b) Displays output on the screen

c)

c) Performs mathematical calculations

d)

d) Defines a variable

3.

3. Which operator is used with cout to send output to the screen? 

a)

a) >>

b)

b) <<

c)

c) ==

d)
  1. d) =


4.

4. What is the correct way to start a new line of output using cout? 

a)

   a) cout << "newline"; 

b)

   b) cout << endl; 

c)

   c) cout << "\n"; 

d)

   d) Both b and c 

5.

 

5. Which of the following is a valid variable name in C++? 

a)

   a) 1stVariable 

b)

   b) _variable 

c)

   c) variable-name 

d)

   d) int 

6.

6. What is the default data type for integer literals in C++? 

a)

a) long 

b)

   b) short 

c)

   c) int 

d)

   d) double 

7.

7. What is the size of the char data type in C++? 

a)

   a) 2 bytes 

b)

   b) 4 bytes 

c)

   c) 1 byte 

d)

   d) 8 bytes 

8.

 

8. Which of the following is a valid way to define a string variable in C++? 

a)

   a) string name = "John"; 

b)

   b) char name = "John"; 

c)

   c) int name = "John"; 

d)

   d) float name = "John"; 

9.

9. What is the result of dividing two integers in C++?

a)

a) A floating-point number

b)

b) An integer with the decimal part truncated

c)

   c) A remainder

d)

d) A double-precision number

10.

10. What does the sizeof operator do in C++? 

a)

    a) Returns the value of a variable 

b)

    b) Returns the size of a data type or variable in bytes 

c)

    c) Performs a mathematical calculation 

d)

    d) Defines a new variable