EasyManuals Logo

Sinclair ZX81 User Manual

Sinclair ZX81
92 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #15 background imageLoading...
Page #15 background image
Chapter 6 - Variables
'My pocket calculator,' you will be saying, 'can store a number away & remember it later. Can your ZX81 do
that?'
Yes. In fact it can store away literally hundreds, using the
LET
statement. Suppose that eggs cost 58p a
dozen, & you want to remember this. Type
LET
EGGS=58 (&
NEWLINE
, of course)
Now first, the computer has reserved a place inside itself where you can store a number, & second, it
has given this place the name 'EGGS' so you can refer to it later. This combination of storage space &
name is called a variable
. Third, it has stored the number 58 in the space: we say that it has assigned the
value 58 to the variable [whose name is] EGGS. EGGS is a numeric variable, because its value is a
number.
Do you want to know how much eggs cost? Type
PRINT
EGGS
If you want to know the cost of half a dozen eggs, then type
PRINT
EGGS/2
In fact, should you want to know the square of the consine of the price of one egg, you can type
PRINT COS
(EGGS/12)**2
'How very easy,' you must think, & you will be wondering what to do next, when in rushes your
housekeeper saying 'Glory be, eggs have just gone up to 61p a dozen.'
Well. There is no time to lose. Type
LET
EGGS=61
This does not reserve any extra storage space, but replaces the old value of 58 with 61. Now you can
type
PRINT
EGGS
confident in the expectation of getting the most up-to-date price available.
Now type
PRINT
MILK
You will get a report 2/0, & looking up 2 in appendix B, you will see that it means 'variable not found' -
the computer hasn't tha faintest idea how much milk costs, because you haven't told it. Type
LET
MILK=18.5
& all will be all right.
(Type
PRINT
MILK
again.)
A variable need not be named after groceries - you can use any letters or digits as long as the first one
is a letter. You can put spaces in as well to make it easier to read, but they won't count as part of the
name.
For instance, these are allowed to be the names of variables:
TWO POUNDS OF APPLES BUT NOT GOLDEN DELICIOUS
RADIO 3

Other manuals for Sinclair ZX81

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair ZX81 and is the answer not in the manual?

Sinclair ZX81 Specifications

General IconGeneral
ProcessorZilog Z80A
Processor Speed3.25 MHz
ROM8 KB
InputMembrane keyboard
StorageCassette tape
Power Supply9V DC
Dimensions167 mm x 40 mm x 175 mm
Release Year1981
ManufacturerSinclair Research
Weight350 g
Operating SystemSinclair BASIC
RAM1 KB
PortsTV out, expansion port
DisplayTelevision (RF modulator output)

Related product manuals