The most basic building block is a variable. They store values that we use in our program. A variable can hold numbers, text, or logical values “true” and “false”.

“sunny” is our variable, and in this case, we can assign it a value of either true or false right above the “If Statement” code, just like this:

sunny = true

if sunny then

print “have a nice day”


print “don’t forget your umbrella”


Variables are the simplest thing to learn, yet without them, our programs would be clueless.

To add numbers, we can use two variables:

int iFirstNumber = 3

int iSecondNumber = 5

print iFirstNumber + iSecondNumber 

When we run this code, it returns the sum of these two variables which is 8.

The int declaration tells a compiler to expect integer variables. It means, in this example, we can only use integer numbers. Anything else would certainly confuse our program.

Next page ->

Leave a comment

Your email address will not be published. Required fields are marked *