Programming instructions
Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Variables • 2
Declaration Rules
In order to declare a variable, you must declare its type, followed by its name. Here are some
specics about the rules governing each:
Proper Variable
Names
Improper Variable
Names
linecounter line counter
threshold threshold!
distance3 3distance
timecounter time1[T1]
Rules for Variable Names
• A variable name can not have spaces in it
• A variable name can not have symbols in it
• A variable name can not start with a number
• A variable name can not be the same as an
existing reserved word
Data Type Description Example Values Code
Integer
Positive and negative whole numbers, as
well as zero.
-35, -1, 0,
33, 100, 345
int
Floating Point
Decimal
Numeric values with decimal points
(even if the decimal part is zero).
-.123, 0.56, 3.0,
1000.07
oat
Boolean
True or False. Useful for expressing the
outcomes of comparisons.
true, false
bool
Character
Individual characters, such as letters and
numbers, placed in single quotes.
‘n’, ‘5’, ‘Z’
char
String
Multiple characters in a row, can
optionally form sentences and words,
placed in double quotes.
“Hello World!”,
“asdf”, “Zebra
Number 56”
string
Rules for Variable Types
• You must choose a data type that is appropriate for the value you want to store
The following is a list of data types most commonly used in ROBOTC:
Variables with Natural Language
Go to Reference Links