HP 48g Graphing Calculator User Manual

Page 419

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

Advertising
background image

the increment value is negative, the loop is executed if the counter is
greater than or equal to finish. Otherwise, execution resumes following
STEP.

FOR...NEXT

Enter this structure into a program by pressing fPRG) EiRuH

S)

FOF:; . Its syntax is

« ... stari finish

F C iR

counter loop-clause

H E !K T ... s -

FOR...NEXT executes the loop-clause program segment one time for
each number in the range start to finish, using local variable counter
as the loop counter. You can use this variable in the loop-clause. The
loop-clause is always executed at least once.

FOR takes start and finish from the stack as the beginning and ending
values for the loop counter, then creates the local variable counter as a

loop counter. Then the loop-clause is executed—counter can appear
within the loop-clause. NEXT increments counter-name by one, and

then tests whether its value is less than or equal to finish. If so, the

loop-clause is repeated (with the new value of counter)—otherwise,

execution resumes following NEXT. When the loop is exited, counter
is purged.

FOR...STEP

Enter this structure by pressing

fPRG) 13

R C H

fr^

F

U

R . Its syntax

is;

29

•K ... start finish l-ijR counter loop-clause increment STEP ... s-

FOR...STEP executes the loop-clause sequence just like FOR...NEXT

does—except that the program specifies the increment value for

counter, rather than incrementing by 1. The loop-clause is always

executed at least once.

FOR takes start and fiinish from the stack as the beginning and ending

values for the loop counter, then creates the local variable counter as a
loop counter. Next, the loop-clause is executed—counter can appear
within the loop-clause. STEP takes the increment value from the

stack and increments counter by that value. If the argument of STEP

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

Programming the HP 48 29-13

Advertising
This manual is related to the following products: