HP 48g Graphing Calculator User Manual

Page 420

Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".

Advertising
background image

29

The increment value can be positive or negative. If the increment is

positive, the loop is executed again if counter is less than or equal to

finish. If the increment is negative, the loop is executed if counter

is greater than or equal to finish. Otherwise, counter is purged and

execution resumes following STEP.

DO...UNTIL...END

Enter this structure into a program by pressing fPRGi

B R C H

&) DO . Its syntax is:

■ i: ... D O

loop-clause

U N T IL

test-clause

E N D ... s -

DO...UNTIL...END executes the loop-clause sequence repeatedly until

test-clause returns a true (nonzero) result. Because the test-clause is

executed after the loop-clause, the loop-clause is always executed at
least once.

DO starts execution of the loop-clause. UNTIL marks the end of

the loop-clause. The test-clause leaves a test result on the stack.

END removes the test result from the stack. If its value is zero,
the loop-clause is executed again—otherwise, execution resumes

following END. If the argument of END is an algebraic or a name, it’s

automatically evaluated to a number.

WHILE...REPEAT...END

Enter this structure into a program by pressing f PRGl i3 R C

Qi-'

. t . Its syntax is:

W H IL E

test-clause

R E P E A T

loop-clause

WHILE...REPEAT...END repeatedly evaluates test-clause and
executes the 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.

WHILE starts execution of the test-clause, which returns a test result

to the stack. REPEAT takes the value from, the stack. If the value
is nonzero, execution continues with the loop-clause—otherwise,

execution resumes following END. If the argument of REPEA.T is an

algebraic or a name, it’s automatically evaluated to a number.

29-14 Programming the HP 48

Advertising
This manual is related to the following products: