Radio Shack TRS-80 User Manual page 160

Micro computer system
Hide thumbs Also See for TRS-80:
Table of Contents

Advertisement

CSAVE!
Before going
on
to the
next
section,
you
may
want
to
save
the square
root subroutine
on
a
cassette,
to avoid the
tedium
of typing
it
in
correctly again
later.
You
can
save
all
the sub-
routines separately,
all
together, or
in
various
combinations. This
will let
you
load
just
the
ones
you
need
for a given
purpose.
From
Square
Roots
to Circles (Well,
Ovals
Anyway!)
While you've
got the square root subroutine loaded,
we'll
demonstrate
how
scientific
sub-
routines
can
be put
to
some
fairly
entertaining
uses.
Type
in
the following
program:
10
CLS
20
FOR
R =
2
TO
22
STEP
4
30
FOR A=-R TO
R
40
X=R*R-A*A
:
GOSUB 30030
!
Y=INT(Y-.5)
50
SET
(A+60.23+Y)
60
SET
(
A+60.23-Y)
70
NEXT
A
80
NEXT
-R
90
GOTD 90
And RUN.
If
you
entered the
program
correctly,
the
Computer
will
generate
a series
of concentric
circles.
The program
uses
the
formula
for finding
the coordinates
of
a
circle
on
a graph:
Y
=
JR*R-X*X
(Y
is
the Y-coordinate,
X
is
the X-coordinate,
and
R
is
the
radius.)
Use
[BREAK]
to get
out
program.
Actually
they're
ovals,
because
the graphics points
ate rectangular instead
at
square
it
would
ta&e
a
slightly
modified
program
to generate
more
perfect
circles.
Care
to
try"?
158

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents