P. 15
Try t h i s :
10 FOR fJ = 1 TO 10
20 PRINT N*N
30 NEXT N
RUN this simple program. What happened? We set up a FOR-NEXT loop.
Line 10 set a series of values for N (from 1 to 10). Line 20
tells the Computer to multiply N times N (the square of N ) . Line
30 tells the Computer to take the next N. This program goes through
10 loops. Change line 10 for more loops. Change line 20 to end
with a comma or semi-colon.
NOTE: A FOR-NEXT loop automatically increases the number by 1,
unless you tell it differently. Change 10 to 10 FOR N =
1 TO 10 STEP 2. RUN it.
Loops can be combined — as long as the loops nest within each
other (ie. finish one loop before going back to the first). Example:
(type in NEW to clear out the memory):
Outer
Loop
("B" Loop is
nested inside
"A" Loop)
Note how we've indented info for the B Loop so you can see it
easier. This technique is a great aid to proper programming.
RUN the program.
The inner loop must be completed before going back to the outer loop.
Loops are extremely useful tools for computer programs. We'll cover
them in great detail in the final User's Manual.