37
The computer creates 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 creates 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 the number 15. The “+” sign tells the computer
to add the numbers found in “A” and “B” together. It computes this and the answer is
23. Now, where is the answer placed? 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 creates one in memory and then puts the answer there.
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.
Now let’s finish this by typing:
50 PRINT “FIRST NUMBER”; A press ENTER
60 PRINT “SECOND NUMBER”; B press ENTER
70 PRINT “THE SUM IS”; C press ENTER
RUN