EasyManuals Logo

HP HP-28S User Manual

HP HP-28S
341 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #230 background imageLoading...
Page #230 background image
2.
The
loop clause
44~:1
.1
BEEP
is
executed.
3.
The
command
NEXT
adds
1 to
the
counter.
4.
The
current
counter
value is
compared
with
the
final
counter
value .
•
If
the
current
counter
value
doesn't
exceed
the
final
counter
value,
steps
(2), (3),
and
(4)
are
repeated
.
•
If
the
current
counter
value exceeds
the
final
counter
value,
the
definite loop
structure
is completed,
and
program
execu-
tion
continues
after
the
NEXT
command.
In this example,
steps
(2), (3),
and
(4) are
repeated
four times.
The
loop
counter
is
first
incremented
from 1 to 2,
then
to 3,
then
to 4,
and
then
to 5. At this
point
it exceeds
the
final value 4, so
the
definite
loop
structure
ends.
Note
that
step
(1)
is
performed
before
any
tests
are
made,
so
the
loop clause is
always
evaluated
at
least once. For
another
example of START '"
NEXT,
see "FIB2 (Fibonacci
Numbers,
Loop Version)"
on
page
248.
FOR counter
...
NEXT
In
many
cases it's
handy
to
use
the
current
value
of
the
counter
as a
variable in
the
loop
clause.
To
do
so, replace START
by
FOR name.
The
counter
becomes
a local variable
with
the
specified
name.
As
be-
fore, this
manual
follows
the
convention
of
writing
local
names
in
lowercase letters to
help
you
distinguish
them
from global
names.
The
following example
puts
the
first five
square
integers
on
the
stack.
1 5 FOR x x
SQ
NEXT
The
sequence
FOR x is executed only once.
The
sequence.-..
:::;Q
is
the
loop clause,
which
is executed repeatedly.
26:
Program
Structures
229

Table of Contents

Other manuals for HP HP-28S

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the HP HP-28S and is the answer not in the manual?

HP HP-28S Specifications

General IconGeneral
BrandHP
ModelHP-28S
CategoryCalculator
LanguageEnglish

Related product manuals