Worksheetschapter 2 C++ Variable Naming Quiz3
Total questions: 10
Worksheet time: 5mins
Which of the following is a valid variable name in C++?
2value
value2
int
float
Which of the following variable names is invalid in C++?
number
student_name
#score
price1
What is the correct way to declare a variable to store a whole number?
int num;
real num;
char num;
float num;
Which of the following is a reserved keyword and cannot be used as a variable name?
main
float
score_1
Name
Which variable name follows all C++ naming rules?
total amount
3value
_totalAmount
@cost
What is the default value of an uninitialized integer variable in C++ (without manual initialization)?
0
1
Undefined / Garbage value
Compiler sets automatically
Which of the following is NOT a valid variable name in C++?
var_123
value$
Value1
_value
What type of value can be stored in a char variable?
Numbers only
Text string
A single character
Boolean value
Which of the following variable declarations is incorrect in C++?
int totalMarks;
float average = 90.5;
char grade = "A";
bool passed = true;
Variable names in C++ are:
Case-insensitive
Must be in capital letters
Case-sensitive
Can start with a number
