39
NOTE
:
For both numeric and string variables, only the first 2 characters of the variable
names are valid. Also, they cannot resemble the name of any command.
Examples
:
TOTAL
is interpreted as the
TO
command and
POTATO
is interpreted as variable
PO
.
5. CONSTANTS
A constant is something that doesn’t change. The computer stores it in memory just like
a variable. However, since a constant doesn’t change it has no variable name. The number
6 is a constant; so is 4.567 or 28967.35. "QUICK BROWN FOX" is a string constant.
You can store constants to a variable. That’s usually done to start out a program; later
the contents of the variables change. Let’s see. Suppose we want to count to 10.
Type in this program:
New
10 N=0
20 N=N+1
30 PRINT N
40 IF N<10 THEN 20
50 PRINT "THE ANSWER IS"; N
RUN
The statement at line 10 stores the numeric constant zero into N, a numeric variable. In
statement 20 the variable will have a numeric constant, 1, added to itself and then the
sum of that operation will be stored in place of the value previously stored there.
Содержание PreComputer Prestige
Страница 1: ...COURSE BOOK...