What are Variables?

Before we look at what variables are, it may be useful to examine another term that is vital to computer programming, that of data.

Data Processing

The whole point of a computer program is to take data and transform it in some way to create information. This gives rise to the idea of the input of raw data, the processing of this raw data into meaningful information and then the output of the information, for example, the raw data may be a 2 and a 3, the process may be an addition, and the output the answer of 5.

Data Process Information
2 and 3 2 + 3        5

In this case, the information is not particularly meaningful. Perhaps a more meaningful example would be a calculation that may be performed in a payroll system.

Data Data Process Information
HoursWorked HourlyRate HoursWorked * HourlyRate GrossPay
10 5.00 10 * 5.00 50.00

It could be concluded that variables, therefore, are data. However, within programming, the concept of a variable is that it can change each time the program is executed.

Note: The * symbol denotes multiplication.

Next: Types of Data