This program calculates the circumference of a circle with a fixed diameter of 35 feet using the formula C = π × D. It uses the built-in PI constant, storing it in variable P before performing the multiplication. The result is printed with a label and unit suffix. Lines 65–80 appear to be utility lines for saving and listing the program rather than part of the normal execution flow, which halts at line 60 with STOP.
Program Analysis
Program Structure
The program is linear and brief, executing from line 20 through line 60 in sequence. Lines 65–80 are never reached during normal execution due to the STOP at line 60.
| Line(s) | Purpose |
|---|---|
| 5–6 | REM comments describing program purpose and usage hint |
| 20 | Assigns built-in PI constant to variable P |
| 30 | Sets diameter D to 35 (feet) |
| 40 | Computes circumference C = P * D |
| 50–55 | Prints label and result with unit |
| 60 | STOP — halts execution |
| 65 | CLEAR — unreachable during normal run |
| 70 | SAVE "1002%2" — saves program; unreachable during normal run |
| 80 | LIST — unreachable during normal run |
Key BASIC Idioms
- The use of
LET P=PIstores the built-inPIkeyword into a scalar variable. This is a common pattern to shorten repeated references, thoughPIis only used once here, making it redundant in practice. - The diameter is hard-coded at line 30 (
LET D=35); the REM at line 6 suggests the author intended to make it user-enterable viaINPUT, but this was never implemented. - Output is split across two
PRINTstatements (lines 50 and 55), the second using a semicolon to append the unit string directly after the numeric value.
Notable Techniques
Lines 65–80 form a developer utility block intended to be run manually after editing: CLEAR resets variables, SAVE preserves the program to tape, and LIST redisplays it. Placing these after a STOP is a common hobbyist practice to keep housekeeping commands in the listing without affecting program flow.
Bugs and Anomalies
- The REM at line 6 promises the ability to enter any diameter, but no
INPUTstatement exists — the diameter is permanently fixed at 35. LET P=PIadds an unnecessary variable assignment sincePIcould be used directly in line 40 asLET C=PI*D.- The apostrophe in
CIRCLES(line 50) is absent — it should readCIRCLE'S— though this is a cosmetic issue only.
Content
Source Code
5 REM CIRCUMFERENCE SOLUTION
6 REM ENTER DIAMETER AS REQUIRED
20 LET P=PI
30 LET D=35
40 LET C=P*D
50 PRINT "THE CIRCLES CIRCUMFERENCE IS :"
55 PRINT C;" FEET."
60 STOP
65 CLEAR
70 SAVE "1002%2"
80 LIST
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
