NEW
Font size
WorksheetsLesson 4 Variables and Arithmetic Operations
Total questions: 12
Worksheet time: 6mins
What must be declared for all variable names in C++?
Only the type
Variable name and type
Variable name and value
Only the variable name
Which of the following is NOT a valid first character for a variable name?
A
1
a
_
What is the purpose of the assignment operator in C++?
To print a value
To declare a variable
To store a value in a variable
To compare two values
Which keyword is used to declare a constant variable?
immutable
static
const
final
What does the setw() manipulator do in C++?
Sets the precision of floating-point numbers
Changes the output format
Fills empty spaces with a character
Sets the field width for output
Which data type is used for decimal numbers in C++?
int
string
float
char
What is the maximum precision of a double data type?
19 decimal points
15 decimal points
10 decimal points
6 decimal points
Which of the following is an arithmetic operator?
&&
==
||
+
What is the correct way to declare a character variable in C++?
char c1(4);
char c1[4];
char c1 = 'a';
char c1 = "a";
What does the setprecision() manipulator do?
Changes the output format
Sets the width of the output field
Sets the number of digits after the decimal point
Fills empty spaces with a specified character
Which of the following is a valid integer data type?
float
string
int
char
Which of the following is NOT a valid C++ keyword?
return
const
variable
class
