When you are Programming you will likely use variables. But what are variables and what are they used for?
What are they?
Variables are containers that are used to store data. I always compare it with a glass of water. You can’t pick up water but if you put water in a glass you can. You can compare water to data and a glass to variables. Without it a computer code can’t interact with the users input.
You will find variables in almost every computer programming code. They may be named differently but their functions stay more or less the same.
What are they used for?
Variables are used to store data and can also be used to edit stored data. For example if you ask the user to type his name in a field you want to say hi to the name that was typed in by the user.
To do this you must make a variable of the text field and once the name has been typed in the name will be stored in the variable. Later you can say hello [name] and use the variable to display the name that has been typed in the text box.
Types
There are many types of variables. Here is a list of some of them.
- Boolean
- Byte
- Integer
- Char
Each of these types is different. For example a Boolean can only store true and false while a byte can only store a small amount of numbers so it is important to use the right type in each situation. The way you use variables in your code depends on the code language. If you use the Warcraft III Editor you need a different code then for example in PHP.