--- title: "Area of Circle" id: 56999 type: "computer_media" slug: "area-of-circle" url: "http://localhost/computer_media/area-of-circle/" markdown_url: "http://localhost/computer_media/area-of-circle.md" published_at: "2024-10-02T07:19:45+00:00" modified_at: "2026-03-30T21:20:20+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/23_Area.png" excerpt: "A compact circle-area calculator using the built-in PI constant, hardwired to radius 5 — then it lists its own source code after saving." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Mathematics" slug: "mathematics" taxonomy: "genre" url: "http://localhost/type/mathematics/" media_contents: - id: 56732 title: "Timex Sinclair Public Domain Library Tape 1001" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1001/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/23_Area.png" media_type_tags: "Mathematics" --- # Area of Circle 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. ## 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 ```