This program is a 20-question multiplication quiz that tests arithmetic with randomly generated numbers. Each question multiplies two integers: one in the range 7–17 and another in the range 5–15, generated using RND and INT. The user’s answer is accepted via INPUT, immediately followed by the correct answer being revealed, with “WELL DONE” printed and the score incremented for a correct response. After all 20 questions, the final score is displayed as a fraction out of 20, and the program saves itself and restarts automatically via RUN on line 95.
Program Analysis
Program Structure
The program is organized into three logical phases:
- Initialization (lines 1–10): Seeds the random number generator with
RANDand resets the scoreSto zero. - Quiz loop (lines 15–75): A
FOR/NEXTloop runs 20 iterations, each generating two random operands, displaying a multiplication question, accepting input, revealing the answer, and awarding a point for a correct response. - Results and restart (lines 80–95): Clears the screen, prints the final score, saves the program, and calls
RUNto restart indefinitely.
Question Generation
The two operands are generated on lines 25 and 30:
M = 7 + INT(RND * 11)— produces a value in the range 7 to 17 inclusive.N = 5 + INT(RND * 11)— produces a value in the range 5 to 15 inclusive.
This means products range from 35 (7×5) up to 255 (17×15), making the quiz moderately challenging for mental arithmetic practice.
Answer Checking
Lines 60 and 65 each independently test Q = M*N. Rather than using a single IF statement with two actions, the condition is evaluated twice — once to print “WELL DONE” and once to increment S. This is a common BASIC idiom on this platform where only a single statement may follow THEN. The correct answer is always revealed on line 55 regardless of whether the user was right or wrong.
Timing and Flow
PAUSE 100 on line 70 inserts a roughly two-second delay after each answer is shown, giving the user time to read the result before the screen is cleared for the next question by CLS at line 20 (at the top of the next iteration).
Notable Techniques
RANDon line 5 (without an argument) seeds the random number generator from the system clock, ensuring a different sequence of questions each run.- Line 45 uses a trailing semicolon after the
PRINTstatement so that the cursor remains on the same line as the question whenINPUT Qon line 50 prompts for entry. - The
SAVEon line 90 followed immediately byRUNon line 95 creates an endless quiz loop with an automatic save between each full round.
Potential Issues
- The correct answer is printed on line 55 before the correctness check on lines 60–65. A user who enters a wrong answer sees the correct answer immediately, which is intentional pedagogically but means there is no opportunity to try again.
- There is no mechanism to display a “WRONG” message when the answer is incorrect — only “WELL DONE” appears for correct answers, leaving incorrect attempts with no explicit feedback beyond the revealed answer.
Content
Source Code
1 REM "TEST"
5 RAND
10 LET S=0
15 FOR I=1 TO 20
20 CLS
25 LET M=7+INT (RND*11)
30 LET N=5+INT (RND*11)
35 PRINT "QUESTION ";I
40 PRINT
45 PRINT M; " * "; N; "=";
50 INPUT Q
55 PRINT M*N
60 IF Q=M*N THEN PRINT "WELL DONE"
65 IF Q=M*N THEN LET S=S+1
70 PAUSE 100
75 NEXT I
80 CLS
85 PRINT "SCORE "; S; " /20"
90 SAVE "1022%1"
95 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
