Sinclair QL Beginner's Manual page 9

Hide thumbs Also See for QL:
Table of Contents

Advertisement

9
Again be careful to put a space after PRINT.
To solve the problem we can write a program which is a sequence of instructions or statements. You
can now understand the first two:
LET dogs = 9 
LET days = 28 
These cause two pigeon holes to be set up, named, and given numbers or values. The next
instruction must perform a multiplication, for which the computer's symbol is *, and place the result in
a new pigeon hole called tins thus:
LET tins = dogs * days 
1. The computer gets the values, 9 and 28, from the two pigeon holes named dogs and days
2. The number 9 is multiplied by 28.
3. A new pigeon hole is set up and named tins.
4. The result of the multiplication becomes the value in the pigeon hole named tins.
All this may seem elaborate but you need to understand the ideas, which are very important.
The only remaining task is to make the computer print the result which can be done by typing
PRINT tins
which will cause the output:
252
to be displayed on the screen.
In summary the program:
LET dogs = 9
LET days = 28
LET tins = dogs * days
PRINT tins
causes the internal effects best imagined as three named pigeon holes containing numbers:
dogs
9
and the output on the screen:
252
Of course, you could achieve this result more easily with a calculator or a pencil and paper You could
do it quickly with the QL by typing:
PRINT 9 * 28 
which would give the answer on the screen. However the ideas we have discussed are the essential
starting points of programming in SuperBASIC. They are so essential that they occur in many
computer languages and have been given special names.
x
days
28
=
tins
252

Advertisement

Table of Contents
loading

Table of Contents