Variables: What are variables?

Variables are areas in your computers memory where you can store data. The reason for calling them variables is that the data can be modified by your program while it is running (unlike, for example, the string "Hello, world" in the previous chapter which stays the same throughout the entire time your program is running).

Variables are used because their values can change and they can be processed in many ways. If their values could not change, your programs would not be able to do anything interesting! The types of processing includes mathematical and logical operations, even if the intention is as simple as counting from 0 to 10.

Every variable is accessed using its name in your source code. A variable name can contain letters (A to Z, a to z), numbers (0 to 9) and the underscore character (_). The variable name cannot start with a number and the letters are case insensitive (so that "MY_VAR23" is the same as "my_var23").

Every variable also has a type, which determines what type of data it can hold, what the range of that data is and how much memory the variable uses.