long variable names, which makes a program easier to follow and easier to
modify. For example, the following are all allowed statements:
LET Length0fCarpet=7.56
LET costof3Tins=1.21
LET SPEED_DF_CAR=60 (the underline character is on the same key as the £)
Although all the examples above have LET before the variable name, its
inclusion is optional. The example program runs just as well if you type:
35 yourmumber=10
As LET is optional you will find it is omitted in most programs.
Whilst variable names may be of any length, they must obey a few simple rules:
-- The variable must begin with an upper- or lower-case letter, the £ or
underline character.
-- The other characters can be upper- or lower-case letters, the £ or underline
character, or numbers.
-- Variables that begin with Basic keywords such as PRINT or LET are not
allowed.
As all Basic keywords are capitalised, it is easy to avoid including keywords at
the start of a variable name by using only lower-case letters in the variable.
This also makes program listings more readable, as the variables stand out.
Integer variables
The variables described so far are known as real variables, because they can be
used to store real numbers -- those with a decimal point. A real variable can be
used to store numbers with up to 9 figure accuracy.
The computer always uses the same amount of memory to store a real quantity,
even if the number stored there is an integer (a whole number). Some
programs only need integers, and using real variables wastes computer
memory. It also slows the program down, because the computer will treat 9 x 8
as 9.00000000 *: 8.00000000 with all the extra calculation this entails!
An integer variable is another sort of numeric variable, and is used to store
only whole numbers in the range --2147483648 to 2147483647. Calculations
with integer variables are much more rapid, and the variables themselves. use
less memory than real variables.
C 5