Subroutines - HP -20S Owner's Manual

Scientific calculator
Hide thumbs Also See for HP-20S:
Table of Contents

Advertisement

(]
10- 61 26
Ends program.
(] [sHOW
7Ab8
Checksum
(page 66).
pag
(-] (PRGM
Exits Program mode.
gr
To store the starting value in R; and run the program:
Keys:
Display:
Description:
5284163
0.5284163_
Enters starting value in
display.
0
0.5284
Stores starting value in
Ry.
A
0.8311
Generates first random
number.
A
0.5579
Generates second ran-
dom number.
Continue pressing
A to continue generating random numbers.
If you want to scale the random numbers to within the range
lower limit < R; < upper limit, add program lines to multiply the ran-
dom number by the difference between the limits, and add the
product to the lower limit. That is:
scaled R; = (upper limit — lower limit)r; + lower limit.
Subroutines
A program is composed of one or more routines. A routine is a func-
tional unit that accomplishes a specific task. As programs get more
complicated, it helps to break them into smaller pieces. This makes a
program easier to write, read, understand, and alter.
A routine typically starts with a label (LBL) and ends with an instruc-
tion that alters or stops program execution, such as RTN or GTO.
76
6: Programming

Advertisement

Table of Contents
loading

Table of Contents