wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Variables in RobotC

Total questions: 15

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following are rules for Variable Names?

a)

A variable name can not have spaces in it

b)

A variable name can have symbols in it

c)

A variable name can not start with a number

d)

A variable name can not be the same as an existing reserved word

2.

Which of the following are proper Variable Names?

a)

line counter

b)

distance3

c)

timecounter

d)

time1[T1]

3.

Which data type has positive and negative whole numbers, as well as zero?

a)

String

b)

integer

c)

Boolean

d)

Floating Point Decimal

4.

Which data type has a string of characters that can include numbers, letters, or typed symbols?

a)

integer

b)

string

c)

boolean

d)

floating point decimal

5.

Which data type uses True or False and is useful for expressing the outcomes of comparisons?

a)

floating point decimal

b)

integer

c)

string

d)

boolean

6.

Which are three main steps involved in using a variable?

a)

Introduce (create or “declare”) the variable

Give (“assign”) the variable a value

Use the variable to access the stored value

b)

Introduce (create or “declare”) the variable

Use the variable to access the stored value

Give (“assign”) the variable a value

c)

Give (“assign”) the variable a value

Introduce (create or “declare”) the variable

Use the variable to access the stored value

7.

True or False? In the declaration the variable is created by announcing its type, followed by its name.

a)

True

b)

False

8.

True or False? During the assignment the variable is assigned a value and a name

a)

True

b)

False

9.

Which of the following are rules for the assignment of variables?

a)

Values are assigned using the assignment operator = (not ==

b)

Math operators (+, -, *, /) can be used with assignment statements to perform calculations on the values before storing them

c)

A variable can not appear in both the left and right hand sides of an assignment statement; this simply means that its current value will not be used in calculating the new value

d)

Assignment can be done in the same line that a variable is declared (e.g. int x = 0; will both create the variable x and put an initial value of 0 in it)

10.

True or False? You can use a variable simply by putting its name where you want its value to be used

a)

True

b)

False

11.

True or False? The current value of the variable will be used every time the variable appears

a)

True

b)

False

12.

Which one is the correct description of the following statement?

sum = variable1 + variable2;

a)

Adds the value in “variable1” to the value in “variable2”

b)

stores the result in the variable “sum”

c)

Adds the value in “variable1” to the value in “variable2”, and stores the result in the variable “sum”

d)

Adds the sum of variable 2 and 2 as the increment

13.

Which is the correct description for the following statement?

count = count + 1;

a)

Adds 1 to the current value of “count” and places the result back into “count” (effectively, increases the value in “count” by 1)

b)

Adds 1 to the current value of “count” and places the result back into “count” (effectively, increases the value in “count” by 2)

c)

Adds the current value of “count” to 1 and places the result plus one back into “count” (effectively, increases the value in “count” by 2)

14.

Which one is the most correct description of the following statement?

int zero = 0;

a)

Add zero as the integer

(combination declaration and assignment statement)

b)

Creates the variable x with an initial value of 0 (combination declaration and assignment statement)

c)

Declare zero as an integer

d)

Declare zero as an initial integer

15.

True or False?

With a robot, however, the ability to store sensor values (values that are measured by the robot, rather than set by the programmer) adds invaluable new capabilities. It gives the robot the ability to take measurements in one place and deliver them in another, or even do its own calculations using stored values.

a)

True

b)

False