FOR...NEXT
Statements
Example 1
Example 2
Example 3
7-112
10 K=10
20 FOR 1=1 TO K STEP 2
30 PRINT Ij
40 K=K+10
50 PRINT K
60 NEXT
RUN
1 20
3 30
5 40
7 50
9 60
Ok
10 J=O
20 FOR 1= 1 TO J
30 PRINT I
40 NEXT I
In this example, the loop does not execute
because the initial value of the loop exceeds
the final value.
10 1=5
20 FOR I
=
1 TO I + 5
30 PRINT Ij
40 NEXT
RUN
1 2 3 4 5 6 7 8 9
10
Ok
In this example, the loop executes ten times.
The final value for the loop variable is always
set before the initial value is set.