44
140 PRINT "YOU MADE A MISTAKE"
150 PRINT "TRY AGAIN"
160 GOTO 30
200 PRINT "THE ANSWER IS";C
300 END
This is a long program but it has a lot of new things in it that are worthwhile to know
about. Line 70 contains an
INPUT
statement without the prompt string. Lines 100 through
130 contain two statements for the thing to do when the condition is true. One is a
LET
statement without the word
LET
(C=A+B) and the other is a
GOTO
statement. Both of
the statements are separated from each other by the colon( : symbol). The
GOTO
statement
tells the computer the number of the next statement to do. Line 140 is an error trap. It
tells you that you have not followed instructions.
You can experiment some more with this program and put in a decision to start the program
all over again.
What happens if you change line 300 to be GOTO 10? Yes, you are right. The program
continues forever. You can stop it by pressing the
Shift
and
Break
keys and resume it
by typing in
CONT
and press
Enter
.
8. LOOPING
A loop is a set of one or more instructions. These instructions can be repeated as many
times as you want. You can create a loop with a
GOTO
statement.
A program like the following will run forever:
10 INPUT "GIVE ME A NUMBER";N
20 PRINT "YOUR NUMBER IS";N
30 GOTO 10
Summary of Contents for PreComputer Prestige
Page 1: ...COURSE BOOK...