Area of Circle

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

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:

  1. 5 — REM comment identifying the program
  2. 10 — assigns the built-in PI constant to variable P
  3. 30 — hardcodes the radius as R=5
  4. 40 — computes the area with A=P*R*R
  5. 50 — prints the formatted result
  6. 60 — saves the program
  7. 70 — 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 30 follows 10 with 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 PRINT statement at line 50 mixes string literals and numeric output using semicolons, producing inline concatenation with the computed value A between two strings.
  • Line 70 executes LIST as a program statement; this causes the interpreter to display the source listing after the SAVE completes, 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

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Related Content

Image Gallery

Area of Circle

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.

People

No people associated with this content.

Scroll to Top