Casio FX-890P Owner's Manual page 54

Casio personal computer owner's manual
Table of Contents

Advertisement

FOR-NEXT
PURPOSE: Executes the program lines between the FOR statement and NEXT
statement and increments the control variable, starting with the initial value.
Execution is terminated when value of the control variable exceeds the specified final
value.
FORMAT:
FOR
control variable
Numeric variable name
|
NEXT
[ control variable ] [ ,
Numeric variable name
EXAMPLE: FOR I=1 TO 10 STEP 0.1
|
NEXT I
PARAMETERS:
1. Control variable: numeric variable name. Array variables cannot be used.
2. Initial value: Numeric expression
3. Final value: Numeric expression
4. Increment: Numeric expression (default value = 1).
EXPLANATION:
1. None of the statements beyween FOR and NEXT are executed and the
program proceeds to the next executable statement after NEXT when the
initial value is greater than the final value.
2. Each FOR requires a corresponding NEXT.
3. FOR – NEXT loops can be nested (a FOR – NEXT loop can be placed inside
another FOR – NEXT loop). Nested loops must be structured as shown below
with NEXT appearing in inverse sequence of the FOR (e.g. FOR A, FOR B,
FOR C – NEXT C, NEXT B, NEXT A).
10 FOR I=1 TO 12 STEP 3
20 FOR J=1 TO 4 STEP 0.5
30 PRINT I,J
40 NEXT J
50 NEXT I
60 END
4. FOR – NEXT loops can be nested up to 29 levels.
5. The control variable may be omitted from NEXT. However, use of the control
variable in the NEXT statement is recommended when using nested loop, to
make the code easier to understand.
6. NEXT statements can be chained by including them under one NEXT
statement, separated by commas.
10 FOR I=1 TO 12 STEP 3
20 FOR J=1 TO 4 STEP 0.5
30 PRINT I,J
40 NEXT J,I
50 END
=
initial value
Numeric expression
[ STEP
control variable
Numeric variable name
54
TO
final value
Numeric expression
increment ]
Numeric expression
] *
P
0

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Z-1grZ-1

Table of Contents