NEW
Font size
WorksheetsSET A
Total questions: 10
Worksheet time: 2mins
1. What is the purpose of the #include <iostream> directive in a C++ program?
a) To define a variable
b) To include input/output functionality
c) To create a new namespace
d) To declare a function
2. What does the cout object do in C++?
a) Reads input from the user
b) Displays output on the screen
c) Performs mathematical calculations
d) Defines a variable
3. Which operator is used with cout to send output to the screen?
a) >>
b) <<
c) ==
d) =
4. What is the correct way to start a new line of output using cout?
a) cout << "newline";
b) cout << endl;
c) cout << "\n";
d) Both b and c
5. Which of the following is a valid variable name in C++?
a) 1stVariable
b) _variable
c) variable-name
d) int
6. What is the default data type for integer literals in C++?
a) long
b) short
c) int
d) double
7. What is the size of the char data type in C++?
a) 2 bytes
b) 4 bytes
c) 1 byte
d) 8 bytes
8. Which of the following is a valid way to define a string variable in C++?
a) string name = "John";
b) char name = "John";
c) int name = "John";
d) float name = "John";
9. What is the result of dividing two integers in C++?
a) A floating-point number
b) An integer with the decimal part truncated
c) A remainder
d) A double-precision number
10. What does the sizeof operator do in C++?
a) Returns the value of a variable
b) Returns the size of a data type or variable in bytes
c) Performs a mathematical calculation
d) Defines a new variable
