Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

chapter 2 C++ Variable Naming Quiz3

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

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

a)

2value

b)

value2

c)

int

d)

float

2.

Which of the following variable names is invalid in C++?

a)

number

b)

student_name

c)

#score

d)

price1

3.

What is the correct way to declare a variable to store a whole number?

a)

int num;

b)

real num;

c)

char num;

d)

float num;

4.

Which of the following is a reserved keyword and cannot be used as a variable name?

a)

main

b)

float

c)

score_1

d)

Name

5.

Which variable name follows all C++ naming rules?

a)

total amount

b)

3value

c)

_totalAmount

d)

@cost

6.

What is the default value of an uninitialized integer variable in C++ (without manual initialization)?

a)

0

b)

1

c)

Undefined / Garbage value

d)

Compiler sets automatically

7.

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

a)

var_123

b)

value$

c)

Value1

d)

_value

8.

What type of value can be stored in a char variable?

a)

Numbers only

b)

Text string

c)

A single character

d)

Boolean value

9.

Which of the following variable declarations is incorrect in C++?

a)

int totalMarks;

b)

float average = 90.5;

c)

char grade = "A";

d)

bool passed = true;

10.

Variable names in C++ are:

a)

Case-insensitive

b)

Must be in capital letters

c)

Case-sensitive

d)

Can start with a number