EasyManua.ls Logo

Radio Shack TRS-80 - Page 160

Radio Shack TRS-80
236 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
Loading...
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

Other manuals for Radio Shack TRS-80

Related product manuals