Variables

Variables are used to represent unknowns, that is, something we don't know the value of when writing a procedure. Variables are what allow us to perform complex mathematical calculations, write multi-purpose functions, and do a large variety of things.


Variables can be declared and initialized on the same line. Initializing a variable ensures that it has a default value.

void main()
{
     int nHours; // declared
     nHours = GetTimeHour() + 4;
     // the below vector is declared and initialized
     vector vPosition = Vector(1.0f, 2.0f, 86.3f);
}

For a list of valid variable data types, see Data Types.




 author: Charles Feduke