wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Variables, Values, and Constants Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a variable in programming?

a)

A constant value that cannot be changed

b)

A predefined keyword in C++

c)

A value stored in a program's execution

d)

A memory location with a name and a type

2.

What are the contents of a variable referred to as?

a)

Value

b)

Identifier

c)

Type

d)

Keyword

3.

What does the assignment operator in C++ do?

a)

Deletes a variable

b)

Copies the value of a variable

c)

Declares a new variable

d)

Increments a variable

4.

What is a constant in programming?

a)

A keyword in C++

b)

A variable that changes its value

c)

A storage entity whose value cannot be changed

d)

A temporary value in a program

5.

What are the components of a C++ program?

a)

Values and literals

b)

Source code and tokens

c)

Comments and keywords

d)

Variables and constants

6.

What is the purpose of an identifier in C++?

a)

To store a value

b)

To declare a variable

c)

To define a constant

d)

To name an entity

7.

What is the size of a bool data type in C++?

a)

4 bytes

b)

2 bytes

c)

8 bytes

d)

1 byte

8.

How can you define a string variable in C++?

a)

Using the 'str' keyword

b)

Using the 'string' class

c)

Including the header file

d)

Declaring it as an array of characters

9.

What is the purpose of the void data type in C++?

a)

To show the lack of any value

b)

To define a constant value

c)

To represent a value that can be true or false

d)

To store floating-point numbers

10.

What is the default size of a floating-point literal in C++?

a)

int

b)

long double

c)

float

d)

double

11.

How can you concatenate strings in C++?

a)

Using the 'concat' function

b)

Using the '+' operator

c)

Using the 'join' method

d)

Using the 'merge' keyword

12.

What is the purpose of a single-line comment in C++?

a)

To terminate the program

b)

To explain the purpose of a part of the program

c)

To span multiple lines

d)

To delete a line of code

13.

What is the purpose of a literal in C++?

a)

To define a variable

b)

To store a memory location

c)

To represent a constant value

d)

To declare a function

14.

How can you define the size of a floating-point literal in C++?

a)

Using the 'precision' function

b)

Using suffixes like 'F', 'L'

c)

Using the 'float' modifier

d)

Using the 'size' keyword

15.

What is the purpose of a multiple-line comment in C++?

a)

To explain the purpose of the whole program

b)

To span multiple lines

c)

To declare a variable

d)

To define a constant value