This program calculates and compares the Cost Per Mille (CPM) — the cost per 1,000 impressions — for two advertising media, such as newspapers or magazines. The user enters a name, ad cost, and circulation figure for each medium; the program divides cost by circulation and multiplies by 1,000 to produce the CPM for each. It then prints both CPM values and identifies which medium offers the lower cost, or reports no difference if they are equal. After displaying results, it waits for a keypress and loops back to accept new inputs.
Program Analysis
Program Structure
The program is straightforward and linear, divided into three functional phases:
- First medium input (lines 10–100): Prompts for name (
N$), ad cost (A), and circulation (C); computes CPM asM = 1000 * (A / C). - Second medium input (lines 110–200): Repeats the same process for variables
P$,Q,R, andS. - Results and loop (lines 210–350): Displays both CPM values, compares them with three
IFstatements, waits for a keypress, clears the screen, and loops back to line 10.
CPM Calculation
The core formula at lines 100 and 200 is standard advertising mathematics: multiply the ratio of cost to circulation by 1,000 to give the cost per thousand readers or viewers. The parentheses around A/C are redundant but harmless, as division already has higher precedence than multiplication.
Key Variables
| Variable | Meaning |
|---|---|
N$ | Name of first medium |
A | Ad cost for first medium |
C | Circulation of first medium |
M | CPM for first medium |
P$ | Name of second medium |
Q | Ad cost for second medium |
R | Circulation of second medium |
S | CPM for second medium |
Notable Techniques
- Keypress wait loop: Line
330usesIF INKEY$="" THEN GOTO 330, a standard busy-wait idiom for pausing execution until any key is pressed. - Three-way comparison: Lines
250–270use three separateIFstatements testingS>M,M>S, andM=Sto cover all cases. This is idiomatic for BASIC dialects lackingELSEorSELECT CASE. - Continuous loop: The program never truly ends during normal use; line
350sends execution back to line10after each comparison, allowing repeated use without restarting.
Bugs and Anomalies
- Line 140 typo:
POKE "AD COST: $ ";should almost certainly bePRINT "AD COST: $ ";. As written, thePOKEkeyword expects two numeric arguments (an address and a value), so this line would produce a syntax or type error at runtime. This is evidently a transcription error in the listing. - Unreachable lines 375–500: Lines
375(CLEAR),400(SAVE "1001%5"), and500(RUN) are never reached during normal execution because the loop at line350returns to line10indefinitely. These lines exist solely for the user toGOTOor execute manually — theSAVEat line400stores the program with an auto-run flag encoded in the filename. - Division by zero risk: If the user enters
0for circulation, lines100or200will cause a division-by-zero error. No input validation is provided.
Content
Source Code
5 REM MEDIA MONEY
6 REM CHOOSE LOWER COST ADS**
10 PRINT "FIRST MEDIUM: ";
20 INPUT N$
30 PRINT N$
40 PRINT "AD COST: $ ";
50 INPUT A
60 PRINT A
70 PRINT "CIRCULATION: ";
80 INPUT C
90 PRINT C
100 LET M=1000*(A/C)
110 PRINT "SECOND MEDIUM: ";
120 INPUT P$
130 PRINT P$
140 POKE "AD COST: $ ";
150 INPUT Q
160 PRINT Q
170 PRINT "CIRCULATION: ";
180 INPUT R
190 PRINT R
200 LET S=1000*(Q/R)
210 PRINT
220 PRINT
230 PRINT N$;" CPM: $ ";M
240 PRINT P$;" CPM: $ ";S
250 IF S>M THEN PRINT N$;" IS LOWER"
260 IF M>S THEN PRINT P$;" IS LOWER"
270 IF M=S THEN PRINT "NO DIFFERENCE"
300 PRINT
310 PRINT
320 PRINT "FOR MORE,PRESS ANY KEY"
330 IF INKEY$="" THEN GOTO 330
340 CLS
350 GOTO 10
375 CLEAR
400 SAVE "1001%5"
500 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
