This program calculates hydrological flood risk, determining the probability that a flood event will be exceeded one or more times within a given time period. It uses the standard complementary probability formula R = 1 − (1 − C/100)^N, where C is the annual exceedance probability in percent and N is the number of years. Input parameters — study name, annual chance percentage, and time period — are supplied via DATA statements at lines 400–420, making the program easy to modify for different scenarios. The result is rounded to the nearest whole percent using the INT(100*R + 0.5) idiom. A PAUSE 340 at line 60 displays variable documentation before clearing the screen for results.
Program Analysis
Program Structure
The program is divided into three logical phases. Lines 20–60 display a brief reference guide describing the three input variables, then pause before clearing the screen. Lines 100–200 read the DATA values, perform the risk calculation, and print the result. Lines 400–430 contain the DATA statements and a STOP to prevent fall-through.
- Documentation display (lines 20–60): Describes T$, C, and N with their line-number locations, then pauses ~6 seconds (PAUSE 340 ≈ 340/50 s on 50 Hz) before clearing.
- Calculation (lines 100–175): Reads study name, annual exceedance percent, and time period; computes likelihood and risk.
- Output (lines 180–200): Prints the study name and a full narrative sentence with the result.
Core Algorithm
The program implements the standard hydrological risk formula. Given an annual exceedance probability C% and a period of N years:
LIKELIHOOD = (1 - C/100)^N— probability the event is not exceeded in any single year, raised to the power of N years.R = 1 - LIKELIHOOD— probability it is exceeded at least once.R = INT(100*R + 0.5)— rounds R to the nearest whole percent.
With the supplied DATA (C=1, N=30), the calculation gives R = 1 − 0.99^30 ≈ 0.2603, rounded to 26 percent — the well-known result that a 100-year flood has roughly a 26% chance of occurring within a 30-year mortgage period.
Data Entry Convention
Rather than using INPUT statements, all parameters are stored in DATA statements placed at deliberately chosen line numbers (400, 410, 420). The documentation in lines 30–50 explicitly references these line numbers, making it straightforward for users to modify the study name, annual probability, and time period without needing to understand the rest of the code. This is a common pattern in early scientific BASIC programs intended for non-programmer end users.
Key BASIC Idioms and Techniques
INT(100*R + 0.5)— standard rounding idiom, sinceINTtruncates toward zero.TAB 10;T$at line 180 — centres the study name label on screen.- Long string literals in PRINT statements (lines 110, 200) rely on word-wrap for display rather than multiple PRINT calls, saving program memory.
PAUSE 340at line 60 provides approximately 6.8 seconds of reading time on a 50 Hz machine before the automatic CLS.
Bugs and Anomalies
| Line | Issue | Effect |
|---|---|---|
| 150 | Variable named LIKELIHOOD | Only the first two characters of a variable name are significant in most Sinclair BASICs; LIKELIHOOD is treated as LI, which is valid but potentially confusing. |
| 175 | Result rounded to integer percent, stored back into R | Precision is lost; for small C values the rounded result could display as 0% even when R is a small positive value. |
| 60 | No INPUT or prompts for C and N | Users must edit DATA lines directly; there is no interactive entry path. |
Content
Source Code
10 REM "Risk"
20 PRINT "Variables:": PRINT
30 PRINT "T$-Name of Study-line 400"
40 PRINT "C-Percent chance in a single year that event will be exceeded-line 410"
50 PRINT "N-time period(years etc) for desired risk computation-line 420"
60 PAUSE 340: CLS
100 READ T$
110 PRINT "C IS PERCENT CHANCE IN A SINGLE YEAR THAT DISCHARGE WILL BE EXCEEDED"
115 PRINT
120 READ C
140 READ N
150 LET LIKELIHOOD=(1-C/100)^N
160 LET R=1-LIKELIHOOD
175 LET R=INT (100*R+.5)
180 PRINT TAB 10;T$: PRINT
190 PRINT
200 PRINT "THE RISK IS ";R;" PERCENT THAT THE SPECIFIED ";C;" PERCENT FLOOD MAY BE EXCEEDED ONE OR MORE TIMES IN A ";N;" YEAR PERIOD"
400 DATA "WILLOW LAKE"
410 DATA 1
420 DATA 30
430 STOP
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

