--- title: "Math Test" id: 57420 type: "computer_media" slug: "math-test" url: "http://localhost/computer_media/math-test/" markdown_url: "http://localhost/computer_media/math-test.md" published_at: "2024-10-05T13:11:47+00:00" modified_at: "2026-03-30T21:18:06+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/221_MTst.png" excerpt: "A 20-question multiplication quiz that picks random number pairs, checks your answers, tallies your score, and loops endlessly — can you beat your high score?" category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Education" slug: "education" taxonomy: "genre" url: "http://localhost/type/education/" - name: "Mathematics" slug: "mathematics" taxonomy: "genre" url: "http://localhost/type/mathematics/" media_contents: - id: 56736 title: "Timex Sinclair Public Domain Library Tape 1005" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1005/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/221_MTst.png" media_type_tags: "Education, Mathematics" --- # Math Test 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: 1. **Initialization (lines 1–10):** Seeds the random number generator with `RAND` and resets the score `S` to zero. 2. **Quiz loop (lines 15–75):** A `FOR`/`NEXT` loop 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. 3. **Results and restart (lines 80–95):** Clears the screen, prints the final score, saves the program, and calls `RUN` to 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 - `RAND` on 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 `PRINT` statement so that the cursor remains on the same line as the question when `INPUT Q` on line 50 prompts for entry. - The `SAVE` on line 90 followed immediately by `RUN` on 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. ## 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 ```