65 wrong=0
70 REPEAT
80 first=RND(12)
90 second=RND(12)
100 PRINT' "What is " ;first;" times " ;second;
110 INPUT response
115 IF response<>first*second THEN wrong=wrong+l
120 answer=answer+1
130 UNTIL TIME>=6000
140 PRINT' "You answered " ;answer;" questions"
145 PRINT '"You had " ;wrong; " wrong"
150 ENDPROC
Line 115 can be extended so that it gives the correct answer as well as counting
the wrong answers:
115 IF response<>first*second THEN wrong=wrong+1:PRINT "No, the ans
wer is ";first*second
Where there are only two possible outcomes, such as an answer being right or
wrong, an extended form of IF...THEN can be used:
115 IF response<>first*second THEN wrong=wrong+1:PRINT "No, the ans
wer is ";first*second ELSE PRINT "Well done! "
In other words, IF the response is wrong, THEN the computer gives the right
answer, ELSE it congratulates you on getting it correct.
The line is beginning to get rather long. To make the program easier to read
and understand it is better to use:
115 IF response<>first*second THEN PR0Cwrong ELSE PR0Cright
and add extra procedures at the end:
160 DEFPROCwrong
170 wrong=wrong+1
180 PRINT "No, the answer is ";first*second
190 ENDPROC
280 DEFPROCright
210 PRINT "Well done!"
220 IF wrong<2 THEN PRINT "Keep it up"
230 ENDPROC
C 42