Math Flasher: Division

This file is part of Timex Sinclair Public Domain Library Tape 1002 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Education

Math Flasher 4 is a division drill program that generates random integer division problems with whole-number answers. It picks two single-digit numbers (0–9), rejecting zero divisors and any pair where P divided by Q is not an integer, ensuring clean division every time. After the user inputs an answer, the program displays CORRECT or WRONG in inverse video, then reveals the correct result before looping back for another problem. The header prints “DIVISION” followed by a row of eight asterisks as a simple visual separator.


Program Analysis

Program Structure

The program is divided into clearly numbered functional blocks:

  1. Lines 5–60: Header display — prints “DIVISION” and a row of eight asterisks as a separator.
  2. Lines 100–130: Problem generation — picks random single-digit integers P and Q, filtering for valid, exact-division pairs.
  3. Lines 200–220: Question display and answer input.
  4. Lines 300–410: Answer checking and feedback.
  5. Lines 500–520: Spacing and loop back to line 10 for the next problem.
  6. Lines 600–700: SAVE and RUN utility lines at the end.

Problem Generation Logic

Lines 100–130 generate two values using INT(10*RND), giving integers in the range 0–9. Two guards are applied:

  • IF Q<1 THEN GOTO 110 — prevents division by zero by re-rolling Q only.
  • IF P/Q<>INT(P/Q) THEN GOTO 100 — rejects non-integer quotients, restarting the entire pair so both P and Q are fresh.

This means problems like 7÷3 are never presented. However, P can be zero, so “0 DIVIDE BY n” is a valid (trivially easy) problem.

Key BASIC Idioms

LineIdiomPurpose
100INT(10*RND)Generate integer 0–9
130P/Q <> INT(P/Q)Test for exact divisibility
310, 400Inverse-video stringsBold visual feedback (WRONG / CORRECT)
520GOTO 10Infinite drill loop

Notable Techniques

Feedback messages at lines 310 and 400 are rendered in inverse video characters, making WRONG and CORRECT stand out visually from the surrounding normal text. Line 410 always prints the correct answer regardless of whether the user was right or wrong, providing immediate reinforcement.

The CLS at line 220 clears the screen immediately after input is entered, before any feedback is shown, keeping the display uncluttered.

Bugs and Anomalies

When the answer is wrong, execution falls through from line 310 to GOTO 410 (line 320), which skips the CORRECT message and lands directly on the answer reveal — this is correct behaviour. However, there is a minor structural oddity: line 300 jumps to 400 on a correct answer, prints CORRECT, then falls through naturally to line 410, which prints the answer again. This means a correct answer causes the answer line to be printed immediately after the CORRECT message with no blank line between them, while a wrong answer gets a GOTO 410 skip. The logic works but the numbering suggests the author considered adding more code between 400 and 410 that was never written.

There is no mechanism to track score or count the number of questions attempted; the program loops indefinitely with no end condition.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Math Flasher: Division

Source Code

   5 REM %M%A%T%H% %F%L%A%S%H%E%R% %4% %D%I%V%I%S%I%O%N
  10 PRINT "DIVISION"
  20 FOR L=1 TO 8
  30 PRINT "*";
  40 NEXT L
  50 PRINT 
  60 PRINT 
 100 LET P=INT (10*RND)
 110 LET Q=INT (10*RND)
 120 IF Q<1 THEN GOTO 110
 130 IF P/Q<>INT (P/Q) THEN GOTO 100
 200 PRINT "DIVIDE ";P;" BY ";Q
 210 INPUT R
 220 CLS 
 300 IF R=P/Q THEN GOTO 400
 310 PRINT "%W%R%O%N%G"
 320 GOTO 410
 400 PRINT "%C%O%R%R%E%C%T"
 410 PRINT P;" DIVIDED BY ";Q;" = ";P/Q
 500 PRINT 
 510 PRINT 
 520 GOTO 10
 600 SAVE "1006%1"
 700 RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top