Declaring and Initalizing Variables

Declaring and Initalizing variables is easy if you know how to do it. Lets start with boolean variables. Boolean variables are either true, or false, like a true or false question on a test. Here's how you write the code!

Boolean x;

x=true;

The top line of code means that the variable, "x", is a boolean variable. The second line of code is initializing the variable, saying that its value is true .

In order to declare and intitalize a string variable, you must type this code

string name;

name = "Brian";

Like last time, the first line is declaring "name" as a variable, and the second line is initalizing the variable by assigning it a value, "Brian."

As we went over in input and output section, declaring integer and double variables are declared as so.

int32 x Double y

x = 20 y = 26.78

The only difference between integers and doubles are that integers cannot have decimals, but doubles can.

Go Back