EasyManua.ls Logo

Radio Shack TRS-80 - Chapter 19: Random Number Generation; RND Function

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...
Chapter
19
A RANDOM
number
is one
with
a value
that
is unpredictable.
A
Random
Number
Genera-
tor pulls
random numbers
out of a hat.
We have a
Random
Number
Generator
and
you set
it up this way:
N
=
RNDtX)
Where N is the random
number
RND is
the
abbreviation
and symbol for
random
X
is
a control number
which can
be either typed
between the
parentheses
or brought
in
as a variable
from elsewhere
in
the program.
Type:
50 PRINT RND(0)
.
. .and RUN.
RUN
it
again
at least
10
times.
Did you observe:
1. A different number
appeared each
time?
2.
All
numbers
were between
and
1?
3. Very
small
numbers
were
expressed
in exponential
notation.
RUN some
more
until
you
are satisfied
that
these
statements
are true.
Wait a
minute
all this
RUNning
is dumb. You
have a Computer!
"Build"
a
FOR-NEXT
loop around
this
Random
Number
Generator
and
let
it run
itself
10
times.
i
vr-\
"RUNNING
IS m-
or
ts
nr*
What program
did
you write?
I wrote:
40 FOR N
=
1
TO
10
50
PRINT RND
(0)
60 NEXT N
99

Other manuals for Radio Shack TRS-80

Related product manuals