The For Construct - HP 49g+ User Manual

Graphing calculator
Hide thumbs Also See for 49g+:
Table of Contents

Advertisement

Use @SST↓@ to step into the program and see the detailed operation of each
command.

The FOR construct

As in the case of the START command, the FOR command has two variations:
the FOR...NEXT construct, for loop index increments of 1, and the FOR...STEP
construct, for loop index increments selected by the user. Unlike the START
command, however, the FOR command does require that we provide a name
for the loop index (e.g., j, k, n). We need not to worry about incrementing
the index ourselves, as done in the examples using START. The value
corresponding to the index is available for calculations.
Commands involved in the FOR construct are available through:
Within the BRCH menu („°@) @ BRCH@) the following keystrokes are available
to generate FOR constructs (the symbol
„ @) @ FOR: Starts the FOR...NEXT construct: FOR
‚ @) @ FOR: Starts the FOR...STEP construct: FOR
The FOR...NEXT construct
The general form of this statement is:
start_value end_value FOR loop_index program_statements
NEXT
To avoid an infinite loop, make sure that start_value < end_value.
Example – calculate the summation S using a FOR...NEXT construct
The following program calculates the summation
„°@) @ BRCH@ @) @ FOR
indicates cursor position):
n
2
S
=
k
k
=
0
NEXT
STEP
Page 21-59

Advertisement

Table of Contents
loading

Table of Contents