EasyManuals Logo
Home>HP>Calculator>40gs

HP 40gs User Manual

HP 40gs
444 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #371 background imageLoading...
Page #371 background image
Programming 21-23
Loop commands
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 Do ... Until ... End is a loop command that executes the
loop-clause repeatedly until test-clause returns a true
(nonzero) result. Because the test is executed after the
loop-clause, the loop-clause is always executed at least
once. Its syntax is:
DO loop-clause UNTIL test-clause END
1
X A:
DO
A + 1
X A:
DISP 3;A:
UNTIL A == 12 END:
WHILE…
REPEAT…
END
While ... Repeat ... End is a loop command that
repeatedly evaluates test-clause and executes loop-clause
sequence if the test is true. Because the test-clause is
executed before the loop-clause, the loop-clause is not
executed if the test is initially false. Its syntax is:
WHILE test-clause REPEAT loop-clause END
1
X A:
WHILE A < 12 REPEAT
A+1
X A:
DISP 3;A:
END:
FOR…TO…STEP
...END
FOR name=start-expression TO end-expression
[STEP increment]; loop-clause END
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:
hp40g+.book Page 23 Friday, December 9, 2005 12:27 AM

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the HP 40gs and is the answer not in the manual?

HP 40gs Specifications

General IconGeneral
BrandHP
Model40gs
CategoryCalculator
LanguageEnglish

Related product manuals