Radio Shack TRS-80 User Manual page 158

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

Advertisement

where
the
triangle
looks
like this:
A
=
3
B
=
4
Okay.
That's not too
grim.
So
let's
write a
program
to find
the
value
of
L,
when
A
=
3
and
B
=
4. If
we
had
the
built-in
square root function
(which
we
don't),
our program might look
like this
:
10
REM
*
SQUARE ROOT SOLUTION WITH SUBROUTINE
*
20
IN.
"THE LENGTH
OF
SIDE
A =
";A
30
IN.
"THE LENGTH
OF
SIDE
B =
";B
40
L
=
SQR(A*A
+
B*B)
50
P.
"A",
"B"
,
"L"
60
P.
A ,B ,L
Now
type
in
the
program
carefully
and
RUN.
Caarash!
The
WHAT?
40
L=S?QR(A*A
+
B*B)
tells
us the
Computer
does not recognize
SQR.
That
means
we'll
have
to
call
up
the
SQR
subroutine
from Appendix
A
to
make
a
workable program.
See the
list
at
the
end
of
this
Chapter
to
determine
which
functions
are available
as
sub-
routines
in
Appendix
A.
Turn
to
page
216
of
Appendix
A
and
find
the
Square
Root
Subroutine.
There
are three
important
things to
look
for
when
checking out
any
subroutine:
1.
What
is
the
input
variable?
2.
What
is
the
output
variable?
156
Whenever
you come
across
a
program
with
aft
intrinsic
function
you
don't
have, you'll
go
";t&roagh
this
same
procedure.
First
type
in
the
§|
subroutine,
then
make
a
few minor changes
in
ed.to#ei^t^;-
:
:
:

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents