This program calculates the area of a circle using the formula A = π × R², with the radius hardcoded to 5 units. It stores π in the variable P via the built-in PI function and computes the area in a single LET statement. The result is printed as a formatted sentence labelling the output in square inches. After saving, the program executes a LIST command to display its own source code.
Program Analysis
Program Structure
The program is a straightforward linear sequence with no loops, branches, or subroutines. It runs from top to bottom in six executable lines:
5— REM comment identifying the program10— assigns the built-inPIconstant to variableP30— hardcodes the radius asR=540— computes the area withA=P*R*R50— prints the formatted result60— saves the program70— lists the program source
Key BASIC Idioms
Storing PI in a single-letter variable P at line 10 is a common optimisation: referencing a numeric variable is marginally faster than evaluating the PI keyword repeatedly, though with only one use here the benefit is negligible. The area formula uses multiplication rather than exponentiation (R*R instead of R^2), which is slightly faster since the power operator involves a more expensive routine.
Notable Techniques and Observations
- The line numbers skip non-uniformly (5, 10, 30, 40, 50, 60, 70) — line
30follows10with a gap of 20, suggesting lines may have been deleted during development. - The radius is hardcoded rather than prompted from the user via
INPUT, making this a single-purpose demonstration rather than a general-purpose tool. - The
PRINTstatement at line50mixes string literals and numeric output using semicolons, producing inline concatenation with the computed valueAbetween two strings. - Line
70executesLISTas a program statement; this causes the interpreter to display the source listing after theSAVEcompletes, which is an unusual post-run behaviour.
Bugs and Anomalies
There are no computational bugs. The formula P*R*R correctly implements πr². The output label “SQUARE INCHES” implies a fixed real-world unit, but since the radius is simply the abstract number 5 with no unit established in the code, this label is technically arbitrary.
Content
Source Code
5 REM AREA OF CIRCLE
10 LET P=PI
30 LET R=5
40 LET A=P*R*R
50 PRINT "THE CIRCLE/S AREA IS ";A;" SQUARE INCHES."
60 SAVE "1002%3"
70 LIST
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
