Let's start looking at how to program for ourselves. The first thing we need to do is to be able to store the results of calculations. Let's think about a program which can add two numbers together. Below is the code for this.

Answer = 1 + 2;

Here we are adding 1 to 2. Clearly the answer is 3, but what do we do with the answer? We must place this answer somewhere so we can do something with it later. We want to put it into a variable.

Lets look at this simple statement in more detail. Before the command above is run, the variable Answer, has a unknown value. Even if we know what value answer has it really does not matter as the code will overwrite the current value of answer. The equals sign in this case does not mean equal to. What it means is assigning to. So reading the above line out load I would say

"I am assigning the value of 3 to the variable Answer"

Rather than

"Answer is now equal to 3"

The assignment operator, =, is one which you will use all of the time and one that can get very confusing.

The variable Answer is stored somewhere in memory. That memory is then assigned the new value of 3 due to the code. This value can be recalled at anytime in order to use it.

next how values get stored >>

 
Install
Menu
Search