Creating Variables in VEXcode Pro V5

What are Variables?

Variables are like containers that store something. Each container “type” possesses a set of properties including size, and what kind of content it can hold.

Two attributes that you should know:


Each variable must have a “type.” This article will cover only the primitive types - char, short, int, long, long long, float, and double.

The primitive data type can hold only scalar values, no dimension to it. Choosing the right type is critical as the type affects how the variable is stored.


Variables must be declared/created before you can use it.


int height;
float amount;

Initialization means pre-populating the variable with an initial value:


height = 5.0;
amount = 0.0;

Or, you can do both declaration and initialization together:

int height = 5.0;
float amount = 0.0;


int length=5, width=10;
Brain.Screen.print("Perimeter of a %d by %d rectangle = %d",
length, width, (length + width)*2 );

Sample to show issues with something not initialized:


Sample to show invalid declaration:


For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: