This program estimates and displays the United States population for a user-supplied date, then enters a real-time loop updating the count. It asks the user to enter a year, month, and day, then applies an exponential growth formula: P = INT(2 × 10^(8 + T)), where T is the fractional number of 150-year periods elapsed since 1969. After displaying the current estimate, it also shows population figures for one minute, one hour, one day, and one week ago, using fixed offsets (4, 231, 5553, and 38874 respectively). A delay loop at lines 440–450 paces the updates before incrementing P by 10 and looping back to redisplay, simulating a live population clock. The title “CENSUS” is displayed in inverse video using the ZX81’s block-graphic character encoding.
Program Analysis
Program Structure
The program is divided into three broad phases: a title/input phase (lines 10–200), a calculation and initial display phase (lines 240–310), and a live-update loop (lines 320–470). Lines 9998–9999 are utility lines for saving and auto-running the program and are not part of the runtime logic.
- Lines 10–50: Display inverse-video title “CENSUS” and scroll down.
- Lines 60–230: Prompt for year (
Y), month (M), and day (D), each separated by sixSCROLLcalls to space the display. - Lines 240–260: Compute the population estimate.
- Lines 270–430: Display current population plus historical offsets.
- Lines 440–470: Delay loop, increment
Pby 10, thenGOTO 280to refresh.
Population Formula
The core calculation occupies lines 240–260:
T = ((Y + M/12 + D/365) - 1969) / 150— normalises the input date to a fraction of a 150-year span from 1969.P = INT(2 × 10^(8 + T))— applies exponential growth anchored so that at epoch 1969, P ≈ 200,000,000 (2 × 10^8), roughly the U.S. population in that year.
The 150-year divisor controls the growth rate; a full 150-year span would multiply the population by a factor of 10, representing an assumed long-term exponential trend. This is a simplification rather than a demographic model.
Historical Offset Constants
Rather than recomputing historical values, the program subtracts hard-coded offsets from P:
| Label | Offset subtracted | Implied rate |
|---|---|---|
| A minute ago | 4 | ~4 persons/minute |
| An hour ago | 231 | ~3.85 persons/minute |
| Yesterday | 5553 | ~3.86 persons/minute |
| A week ago | 38874 | ~3.86 persons/minute |
The per-minute rate of approximately 3.85–4 is broadly consistent with U.S. net population growth figures from the early 1980s (roughly 2 million per year ÷ 525,600 minutes ≈ 3.8/minute). The slight inconsistency between the “minute” offset (4) and the others is a minor rounding artefact.
Live Update Loop
Lines 440–470 implement the real-time clock behaviour. The FOR N=1 TO 3000: NEXT N busy-wait loop provides a software delay intended to approximate one minute of elapsed time, after which P is incremented by 10 and the display block (lines 280–430) is repeated via GOTO 280. The increment of 10 per iteration is notably inconsistent with the per-minute offset of 4 used in line 340; this means the displayed “current” population will drift faster than the historical comparisons would predict.
Key BASIC Idioms
- Repeated
SCROLL: Used in groups of two or six throughout to create visual spacing on the ZX81’s 32-column display without usingPRINTblank lines, avoiding the need to manage cursor position explicitly. - Inverse-video title: Line 20 uses
TAB 10;"% %C%E%N%S%U%S% "where each%Xencodes an inverse-video character, producing a highlighted title banner. INT Pwithout parentheses: Line 260 usesLET P=INT P, the ZX81 BASIC shorthand whereINTtakes the immediately following token as its argument — valid syntax on this platform.- Utility lines 9998–9999: Storing
SAVEandRUNat high line numbers is a common convention to keep housekeeping commands accessible without interfering with normal execution flow.
Content
Source Code
10 SCROLL
20 PRINT TAB 10;"% %C%E%N%S%U%S% "
30 FOR N=1 TO 6
40 SCROLL
50 NEXT N
60 PRINT "WHAT YEAR IS IT? ";
70 INPUT Y
80 PRINT Y
90 FOR N=1 TO 6
100 SCROLL
110 NEXT N
120 PRINT "WHAT MONTH (1 - 12)? ";
130 INPUT M
140 PRINT M
150 FOR N=1 TO 6
160 SCROLL
170 NEXT N
180 PRINT "DATE (1 - 31)? ";
190 INPUT D
200 PRINT D
210 FOR N=1 TO 6
220 SCROLL
230 NEXT N
240 LET T=((Y+M/12+D/365)-1969)/150
250 LET P=2*10**(8+T)
260 LET P=INT P
270 PRINT "DATE: ";M;"/";D;"/";Y
280 FOR N=1 TO 6
290 SCROLL
300 NEXT N
310 PRINT "U.S. POPULATION",P
320 SCROLL
330 SCROLL
340 PRINT "A MINUTE AGO",P-4
350 SCROLL
360 SCROLL
370 PRINT "AN HOUR AGO",P-231
380 SCROLL
390 SCROLL
400 PRINT "YESTERDAY",P-5553
410 SCROLL
420 SCROLL
430 PRINT "A WEEK AGO",P-38874
440 FOR N=1 TO 3000
450 NEXT N
460 LET P=P+10
470 GOTO 280
9998 SAVE "CENSU%S"
9999 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
