HP 48gII Advanced User's Reference Manual page 46

Graphing calculator
Hide thumbs Also See for 48gII:
Table of Contents

Advertisement

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 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.
To enter FOR ... NEXT in a program:
Press !°%BRCH% ! %FOR%.
!
Example:
The following program places the squares of the integers 1 through 5 on the stack:
« 1 5 FOR j j SQ NEXT »
Example:
The following program takes the value x from the stack and computes the integer powers i of x. For
example, when x =12 and start and finish are 3 and 5 respectively, the program returns 12
requires as inputs start and finish in level 3 and 2, and x in level 1. ( x removes x from the stack, leaving start
and finish there as arguments for FOR.)
«  x « FOR n 'x^n' EVAL NEXT » »
The FOR ... STEP Structure
The syntax for this structure is
« ... start finish FOR counter loop-clause increment STEP ... »
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.
1-20 RPL Programming
Syntax
Start
finish
FOR
loop-clause
NEXT
FOR ... NEXT Structure
Flowchart
1:Start
2:finish
counter=start
Store finish
Body of loop
counter = counter + 1
Is
yes
counter finish?
no
3
4
5
, 12
and 12
. It

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

49g+

Table of Contents