hp40g+.book Page 23 Friday, December 9, 2005 1:03 AM
DO…UNTIL …END
WHILE…
REPEAT…
END
FOR…TO…STEP
...END
Loop hp allow a program to execute a routine repeatedly. The HP 40gs has three loop structures. The example programs below illustrate each of these structures incrementing the variable A from 1 to 12.
Do ... Until ... End is a loop command that executes the
DO
1 X A:
DO
A + 1 X A:
DISP 3;A:
UNTIL A == 12 END:
While ... Repeat ... End is a loop command that repeatedly evaluates
WHILE
1 X A:
WHILE A < 12 REPEAT
A+1 X A:
DISP 3;A:
END:
FOR
FOR A=1 TO 12 STEP 1;
DISP 3;A:
END:
| Note that the STEP parameter is optional. If it is omitted, |
| a step value of 1 is assumed. |
BREAK | Terminates loop. |
| BREAK: |
Programming |
| ||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|