The program prints:
The variable contains 53
Look at the (first) program again:
' Program that uses a variable ' LET NUM = 23.5 PRINT "The variable contains", NUM END
In this program, NUM is a variable.
The programmer chose the name NUM .
When the program runs,
several things happen when the LET statement executes:
NUM
So after this statement has executed a section of memory
named NUM holds 23.5:
| 23.5 |
After the first statement has executed, the second statement executes:
PRINT "The variable contains", NUM
The variable NUM already exists,
so no more memory is reserved for it.
The PRINT statement does several things:
NUM for a number.So on the monitor you see:
The variable contains 23.5
What do you think the following program will write to the monitor?
' Program with a variable ' LET VALUE = 2 + 3 PRINT "The result is", VALUE END