Atari 400 Users Handbooks page 69

Hide thumbs Also See for 400:
Table of Contents

Advertisement

Introduction
to
Atar
i
BASIC 67
The
loop
will continue to be executed
until
r\
atta
ins
a value
greater than
20.
When this
occu
rs
,
the
statement
following the
NEXT statement will be
executed.
In
our preceding
example,
A is known
as an
index variable.
If
the
optional keyword STEP is not
in cluded
w
ith
the
FOR
statement,
the
index
variable will be
incremented
by
1
every
time
the
NEXT
statement is executed.
STEP can
be
included
at
the
end
of a FOR
statement
to change
the value
by
which th
e
inde
x
variable
is incremented
.
The
integer
appearing
after
STEP
is
the
new in
creme
nt.
For example,
if our preceding
exa
mple
were
changed
as follows
,
100 FOR
A
=
1
TO
20 STEP 2
200
X
=
A
A
2
300 PRINT X
400 NEXT A
500
END
the
inde
x
variable A would be
incremented
by 2
eve
ry time the
NEXT
state
ment
was
executed.
Nested Loops
One loop
can be placed
inside
of another
loop.
Th
e
innermost
loop is
known as a nested
loop. The
following program contains
a
nested
loop.
100
P
=
1000
200 FOR Y
=
1
TO 10
300 FOR
Q
=
1 TO
4
400 P
=
P +
P
*
.02
500
NEXT
Q
600 NEXT Y
650 PRINT
P
700 END
Our
preceding
examp le
is
used
to
calculate the value of
1000
after
10
years with an interest
rate
of
8%
compounded
quarterly.
On
e
error
that
yo
u
should take
care
to
avoid
when
using nested

Advertisement

Table of Contents
loading

This manual is also suitable for:

800

Table of Contents