wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Lesson 4 Variables and Arithmetic Operations

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

What must be declared for all variable names in C++?

a)

Only the type

b)

Variable name and type

c)

Variable name and value

d)

Only the variable name

2.

Which of the following is NOT a valid first character for a variable name?

a)

A

b)

1

c)

a

d)

_

3.

What is the purpose of the assignment operator in C++?

a)

To print a value

b)

To declare a variable

c)

To store a value in a variable

d)

To compare two values

4.

Which keyword is used to declare a constant variable?

a)

immutable

b)

static

c)

const

d)

final

5.

What does the setw() manipulator do in C++?

a)

Sets the precision of floating-point numbers

b)

Changes the output format

c)

Fills empty spaces with a character

d)

Sets the field width for output

6.

Which data type is used for decimal numbers in C++?

a)

int

b)

string

c)

float

d)

char

7.

What is the maximum precision of a double data type?

a)

19 decimal points

b)

15 decimal points

c)

10 decimal points

d)

6 decimal points

8.

Which of the following is an arithmetic operator?

a)

&&

b)

==

c)

||

d)

+

9.

What is the correct way to declare a character variable in C++?

a)

char c1(4);

b)

char c1[4];

c)

char c1 = 'a';

d)

char c1 = "a";

10.

What does the setprecision() manipulator do?

a)

Changes the output format

b)

Sets the width of the output field

c)

Sets the number of digits after the decimal point

d)

Fills empty spaces with a specified character

11.

Which of the following is a valid integer data type?

a)

float

b)

string

c)

int

d)

char

12.

Which of the following is NOT a valid C++ keyword?

a)

return

b)

const

c)

variable

d)

class