top of page

Shane Partridge Mathematics
Basic Computer Programming Language
Read & Data Programming Statements
Validated by If Test Than Statement


5 'Rem Program [1]
10 Read AGE
20 If Age > 18 then 99
30 Print AGE 'Rem Variable not under Validation Line 20
40 Goto 10
60 Data 17 , 1 , 12 , 15
99 End
This Loop begins with a Read Statement, because the GOTO Statement at the end of the Loop always branches to Line 10. The READ Statement initializes and modifies the value of Variable AGE.
But does not Test the Variable.
So when the Program Runs :
Run
17
1
12
15
Out of Data in Line 10 : Error command
Breaching Out of Data Error Code.
The same Loop is better designed as follows in the below Program
5 'Rem Program [2]
10 Read AGE
20 if AGE > 18 Then 99
30 Print AGE
40 Read AGE 'Rem Variable under Validation of Line 20
50 Goto 20
60 Data 17 , 1 , 12 , 15, 20
99 End
Note Line 40 Reads the Data inside the For Next Loop Execution.
As opposed to the First Program.
The AGE Variable is then Validated by the If Test Then Statement.
Omitting any Out of Data Error Commands as in Program [1]
Line 10 Read AGE Reads the first Data Value. But line 40 continues on
reading inside the For Next Loop Statement under Validation.
The Data in Line 60 Validated by Line 20 through the Read command
of Line 40 . When run command is executed No out of Data Error is
Code is Breached
So when Run command is Executed
Run
17
1
12
15
ok
Prompt Execution of If Then Test Statements and
Read and Data Command Functions
2 'Rem For/Next Loop Statement
5' Rem Also Classified as the Self-Increment Type Loop
10 Sum = 0
20 For I = 1 to 10
30 Read Number
40 Sum = Sum + Number 'Concatenation or Incrementation
50 Next I
60 Print Sum
70 Data 4 , 15 , 72 , 80 , 6 , 29 , 34 , 42 , 96 , 9
99 End
Execute Run Command.
Run
387
When the program is executed, the Numeric Data is line 70 is
incremented Line 40 - Sum = Sum + Number .
Line 30 Executes the Read Function while Line 40 Increments the
Read Variable [Number]
The Limit of the Loop is Classified by Line 20 For I = 1 to 10
The Loop is then returned by Line 50 Next I.
Once Line 50 Next I - Has Reached Value of 10 Then line control
drops to Line 60 to Print Sum Variable.
For/Next Loop Statement - Self Incrementing Type Loop.
bottom of page