Commodore 64 User Manual page 50

Hide thumbs Also See for 64:
Table of Contents

Advertisement

CT is incremented by 1. The NEXT statement in line 30 automatically
sends the program back to line 10 where the FOR part of the FOR .. .
NEXT statement is located. This process will continue until CT reaches the
limit you entered.
The variable used in a FOR . . . NEXT loop can be incremented by
smaller amounts than 1, if needed.
Try this:
NEW
10 FOR NB = 1 TO 10 STEP .5
20 PRINT NB,
30 NEXT NB
RUN
1
1.5
2
2.5
3
3.5
4
4.5
5
5.5
6
6.5
7
7.5
8.5
9
9.5
10
If you enter and run this program, you'll see the numbers from 1 to
10, by .5, printed across the display.
All we're doing here is printing the values that NB assumes as it goes
through the loop.
You can even specify whether the variable is increasing or decreas-
ing. Substitute the following for line 10:
10 FOR NB = 10 to 1 STEP -.5
and watch the opposite occur, as NB goes from 10 to 1 in descending
order.
S
0
S
40

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for Commodore 64

Table of Contents