EasyManua.ls Logo

Radio Shack TRS-80 - Page 72

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...
Taking
it a
line
at a
time:
Line 30
set
the value of X
(or any of our 26
alphabet^oup
variables)
equal to
the value
we
selected,
in this case n.
Line 40
finds
the INTEGER
value of the above
number and assigns it a
variable name.
We
chose
Y.
Line
50
prints a
little identification
(Y=) followed
by the value of Y.
Not
Content to
Leave
Well
Enough Alone
We can do
some
foxy
things
you
probably
never
thought of by
combining a
FOR-NEXT
loop
with the
INTEGER
function.
Change
the
program to
read
:
30 X
=
3.
14159
40
Y
=
INT(X)
50 Z
=
X
-
Y
60
PRINT
"
X
=
"
;X
70
PRINT
i
"
Y
=
"
jV
80
PRINT
"
Z
=
"
tZ
...
and
RUN.
AHA! I
don't
know
what we've
discovered
but it
must be good
for something.
It reads:
X
=
3.
14159
Y
=
3
Z
=
.
141589
We've split
the value
of
X into
its Integer
(whole
number)
value and
called it
Y,
and
its
decimal
value and
called it Z.
Line
60,
70
and
80
merely
printed
the
results.
Hold the
phone!!!
Oh
oht Why
doesn't Z
equal the exact
difference
between
X
and Y?
Where did that
"8"
come
from in
the
decimal value?
70

Other manuals for Radio Shack TRS-80

Related product manuals