--- title: "Ohm’s Law" id: 64652 type: "computer_media" slug: "ohms-law-2" url: "http://localhost/computer_media/ohms-law-2/" markdown_url: "http://localhost/computer_media/ohms-law-2.md" published_at: "2026-03-06T14:54:03+00:00" modified_at: "2026-03-30T21:44:20+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/03/Ohms-Law.png" excerpt: "Enter any two electrical values and this Ohm's Law calculator instantly derives voltage, current, resistance, and power using all six possible formula pairs." 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 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Education" slug: "education" taxonomy: "genre" url: "http://localhost/type/education/" - name: "Electronics" slug: "electronics" taxonomy: "genre" url: "http://localhost/type/electronics/" media_contents: - id: 64613 title: "CATS Library Tape 10" type: "computer_media" url: "http://localhost/computer_media/cats-library-tape-10/" - id: 54965 title: "ISTUG Public Domain Library 5" type: "computer_media" url: "http://localhost/computer_media/istug-public-domain-library-5/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Ohm%27s%20Law%20%28198x%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2026/03/Ohms-Law.png" media_type_tags: "Education, Electronics" --- This program is an Ohm’s Law calculator that derives all four electrical quantities — voltage (V), current (I), resistance (R), and power (P) — from any two known values entered by the user. The user inputs known quantities and enters 0 for unknowns; the program then applies whichever of the six possible two-variable formulas can be satisfied. All standard relationships are covered: P=VI, R=V/I, I=√(P/R), V=√(PR), V=P/I, R=P/I², P=V²/R (note a bug here), I=V/R, P=I²R, V=IR, R=V²/P, and I=P/V. The program is saved with an auto-run LINE 1 directive so it launches immediately on load. *** ## Program Structure The program is organized into three broad phases: 1. **Initialisation (lines 10–175):** REM banner, variable zeroing, and prompt display. 2. **Input collection (lines 180–365):** Sequential prompts for V, I, R, and P, with early exits via `GO TO 390` once enough known values have been entered. 3. **Formula evaluation (lines 390–570):** Six guarded blocks, each checking whether two specific variables are non-zero before printing the derived quantities. ## Input / Early-Exit Logic The program uses truthiness of numeric variables as boolean flags: a value of 0 is “false” (unknown) and any non-zero value is “true” (known). After collecting V and I, line `270` tests `IF V AND I THEN GO TO 390`; if both are known no further input is needed. Line `330` similarly skips the power prompt when either V+R or I+R are both known. This means a user can supply exactly two values and the program proceeds to the output section. ## Formula Coverage | Lines | Known pair | Derived quantities | | --- | --- | --- | | 390–410 | V, I | P = V×I, R = V/I | | 420–440 | P, R | I = √(P/R), V = √(P×R) | | 450–470 | P, I | V = P/I, R = P/I² | | 480–500 | R, V | P = V²×R *(bug — see below)*, I = V/R | | 510–530 | I, R | P = I²×R, V = I×R | | 540–560 | V, P | R = V²/P, I = P/V | ## Notable Bug Line `490` reads `PRINT "Power (P)=";(V^2)*R;" W"`. The correct formula for power given voltage and resistance is P = V²/R, not V²×R. The multiplication sign should be a division sign. The complementary formula on line `500` (`I = V/R`) is correct, so this is an isolated arithmetic error rather than a structural fault. ## Key BASIC Idioms - **Zero-as-false guard:**`IF NOT V OR NOT I THEN GO TO 450` — each output block is skipped unless both required variables are non-zero, neatly encoding “do we have enough information?” - **Compound boolean in input phase:** Line `330` uses `IF V AND R OR I AND R` to check two sufficient pairs simultaneously before prompting for P. - **Inline echo:** After each `INPUT` the program immediately PRINTs the accepted value with its unit (lines 210, 260, 320, 365), confirming the entry to the user. - **Auto-run save:** Line `9998` uses `SAVE "OHM'S LAW" LINE 1` to embed the start line in the tape header, so the program runs automatically on `LOAD`. - **Exponentiation notation:** The caret `^` is used for powers (e.g., `I^2`, `V^2`); line `475` even includes a REM explaining this for less-experienced users. ## Variable Initialisation Lines 120–150 explicitly set `v`, `I`, `R`, and `P` to 0. Note that line `120` uses lowercase `v` while the rest of the program uses uppercase `V`; on this platform variable names are case-sensitive, so `v` and `V` are distinct variables. The initialisation of `v` at line 120 is therefore redundant with respect to `V` as used in the input and calculation sections, though in practice both will default to 0 anyway. ## Program Flow Anomaly Line `50` prints the title banner before line `100` clears the screen (`CLS`), so the title appears only briefly and is immediately erased. This appears to be an oversight; the banner in the REM block (lines 10–21) is never actually displayed to the user, and the `PRINT` at line 50 is functionally invisible. ## Source Code ``` 10 REM ////////////////////// 12 REM / / 13 REM / OHM'S LAW / 20 REM / / 21 REM ////////////////////// 50 PRINT " OHM'S LAW " 100 CLS 120 LET v=0 130 LET I=0 140 LET R=0 150 LET P=0 170 PRINT "Input known values" 175 PRINT " 0 If unknown" 176 PRINT 177 PRINT 178 PRINT 180 PRINT ;"voltage (V)="; 190 INPUT V 210 PRINT V;" V" 230 PRINT ;"Current (I)="; 240 INPUT I 260 PRINT I;" A" 270 IF V AND I THEN GO TO 390 290 PRINT ;"Resistance (R)="; 300 INPUT R 320 PRINT R;" Ohms" 330 IF V AND R OR I AND R THEN GO TO 390 350 PRINT ;"Power (P)="; 360 INPUT P 365 PRINT P;" W" 390 IF NOT V OR NOT I THEN GO TO 420 400 PRINT "Power (P)=";V*I;" W" 410 PRINT "Resistance (R)=";V/I;" Ohms" 420 IF NOT P OR NOT R THEN GO TO 450 430 PRINT "Current (I)=";SQR (P/R);" A" 440 PRINT "Voltage (V)=";SQR (P*R);" V" 450 IF NOT P OR NOT I THEN GO TO 480 460 PRINT "Voltage (V)=";P/I;" V" 470 PRINT "Resistance (R)=";P/(I^2);" Ohms" 475 REM ^ = raised to the power of 480 IF NOT R OR NOT V THEN GO TO 510 490 PRINT "Power (P)=";(V^2)*R;" W" 500 PRINT "Current (I)=";V/R;" A" 510 IF NOT I OR NOT R THEN GO TO 540 520 PRINT "Power (P)=";(I^2)*R;" W" 530 PRINT "Voltage (V)=";I*R;" V" 540 IF NOT V OR NOT P THEN GO TO 570 550 PRINT "Resistance (R)=";(V^2)/P;" Ohms" 560 PRINT "Current (I)=";P/V;" A" 570 PRINT 571 PRINT 572 PRINT 573 PRINT 1000 STOP 9998 SAVE "OHM'S LAW" LINE 1 ```