INPUT statement makes the computer wait for you to type something -- in this

case a number. Type:

6 RETURN

Once you have typed the number, line 30 is obeyed and the message displayed

is:

You typed 6

Line 20 causes the computer to store your number in a variable, so called

because its value can vary. Here the variable is called yournumber. You can

think of a variable as an internal pigeon-hole which the computer fills with a

value, in this case 6.

Whenever the computer comes across any reference to yournumber in the

program, it uses the current value of the variable. So line 30 causes the

computer to print You typed, then find the value of the variable yournumber,

and finally print that value, 6.

RUN the program again, inputting a different number, and watch the effect.

yournumber is a numeric variable -- it can be used to store the value of whole

numbers, decimals, or negative numbers. Variables can be used in arithmetic --

add these lines to the program and RUN it again:

40 PRINT "Twice " ;yournumber; " is " ;2*yournumber

50 PRINT "Subtract 5 from ";yournumber;" and you get '';yournumber-5

60 PRINT"Add 28 to " ;yournumber;" and you get " ; 20+yournumber

The value of a variable does not have to be input, it can be given directly. For

example, type:

LET height=2 RETURN

Then type:

PRINT height RETURN

PRINT height*2 RETURN

You can change your program to include a LET statement by adding these

lines:

35 LET yournumber=10

36 PRINT "But the new value is " ;yournumber

LIST the program so that you can see the order in which the computer obeys

the instructions, and then RUN the extended program.

In the versions of BASIC provided on some computers only very short variable

names like Q or AB are allowed. BBC BASIC, on the other hand, lets you use

C 4