Commodore PET User Manual page 72

Table of Contents

Advertisement

The same three numbers, 10,20, and 30, are displayed, but A, B, and C are
variables, not constants. By changing the values assigned to A, B, and C, Vou can
change the values printed out by the PRINT statement Here is an example:
A=-4B=10'C=4E2PRINT A,B,C
-4
10
400
Variables appear in just about every statement of a computer program.
Variable Name
A variable is identified by a name. We used A, B, and C as variable names in
the illustrations above. A variable has two parts: its name and a value. The
variable name represents a location at which the current value is stored.
1
n
the illustration below, the cu rrent va lue of A is 14; for B it is 15; and for C it is O.
Variable
Location
Name
Contents
A
14
B
15
C
0
If we change A to -1 using the immediate mode statement:
A =-1
then our illustration must change as follows:
Variable
Name
A
B
C
Location
Contents
-1
15
o
This is a good way of looking at variables because it is, in fa ct the way they
are handled by the PET.
A variable name represents an address in PET
memory; and at that memory location is the current value of the variable. The
important point to note is that variable names - which are names that pro-
grammers make up - are arbitrary; they have no innate relationship to the
value that the variables represent.
59

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents