ChaDter 51
Basic
ConceBts
This line contains
4
string constants: NAME, ADDRESS, CITY,
and STATE. These values will not change. Every time BASIC ex-
ecutes this statement, the same 4 words are printed.
PRINT “1 000 PLUS”; 2000; “EQUALS”;3000
The 1000
is
a string constant, the 2000 and the 3000 are nu-
meric constants.
Variables
Variables are symbolic names for a value in a BASIC program. A
variable name can be a maximum of 40 characters and must be-
gin with
a
letter (A-Z).
Note:
You cannot use any of the reserved words listed
in Appendix A as variable names. However, reserved
words may be imbedded in a variable name.
The following are examples of variable names:
A A1
ADDRESS ADDRESS. OLD
L
L2
LEN2
LENGTH
The
2
types of variables are string and numeric. BASIC initially
classifies all variables
as
single precision with a value
of
zero
(0). (The next section describes how to declare variables as
string, integer, or double precision variables.)
The following examples assign a value
to
a variable.
LET
A
=
12345
A
=
601 .432
BALANCE
=
338.92
BASIC automatically stores all the above examples as single pre-
cision numbers. Chapter 10, “BASIC Keywords,” describes more
ways to assign values to variables.
Declaring Numeric Constants and Variables
BASIC lets
you
override its automatic classification of numeric
constants and variables.
47