36
3. NUMERIC VARIABLES
You have seen how you can use BASIC to print numbers and messages. You can also
give values to a BASIC program yourself. The computer uses a letter to stand for a value.
This is called a variable. For example LET D = 609. This statement puts the value 609
into a box in memory called "D".
Try this. Type:
10 LET A=8
press
Enter
The computer makes a box in memory and calls it "A". It puts the number 8 in this box.
Now type:
20 LET B=10
press
Enter
The computer makes a box called "B" and places 10 into it.
Type:
30 LET B=15
press
Enter
Since there is a box called "B" already with a value of 10 in it, it doesn’t make another
box called "B" with a value of 15 in it. The number 10 is just replaced with the number
15.
Now type:
40 LET C=A+B
press
Enter
This statement is a bit more complicated. Here’s how it works. First, the computer searches
for a memory box called "B" and finds in it the number 15. The "+" sign tells the computer
to add the numbers found in "A" and "B" together. It does that and the answer is 23.
Now, where to put the answer? No problem. The "=" tells the computer to store the answer
in a memory box called "C". The computer searches for a box called "C". It doesn’t find
one so it makes one in memory and then puts the answer into it.
Of course, if there was a memory variable called "C" that had a number in it from a previous
operation, the old number would be replaced by the new one in this statement.
Summary of Contents for PreComputer Prestige
Page 1: ...COURSE BOOK...