EasyManua.ls Logo

Commodore Plus 4 - Page 73

Commodore Plus 4
234 pages
Print Icon
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...
-
Lets
examine
how
your
Plus/4
handles
random
numbers,
and
some
of
the things
you
can
do
with
them
This
program
generates
five
com
pletely
random
numbers
10
FOR
X-
1
TO
5:PRINT
RND(X):NEXT
X
These
random
numbers
are
all
rather
complex,
with
several
p;aces
on
the
right
side
of
the
decimal
point...
but
most
uses
for
random
numbers
require
whole
numbers
You
can
make
your
numbers
come
out
as
whole
numbers
(without
decimal
places)
by
using
the
INTeger
function,
which
cuts
off
all
the
digits
on
the
right
side
of
the
decimal
point.
The
following
gives
you
a
formula
for
generating
random
num
bers
in
any
range
you
want.
You
can
use
this
formula
almost
anywhere
you
would
use
a
variable
or
number
in
your
program,
INT(range"
RND(l))
lower
limit
The
INT
command
tells
the
computer
to
cut
off
any
decimal
places
and
only
give
you
whole
numbers
like
1,
45.
or
320,
instead
of
numbers
like
1.223,
45,6677,
or
320.59.
Whole
numbers
are
easier
to
work
with
when
using
random
numbers.
Lower
Limit
in
the
formula
refers
to
Ihe
lowest
number
you
want
the
computer
to
choose
from.
Range
is
how
many
numbers
are
in
the
total
group.
For
example,
if
you
want
to
choose
a
random
number
from
1
to
5.
Ihe
lower
limit
is
1
and
the
range
is
5.
If
you
want
to
choose
a
random
number
from
15
to
20.
the
lower
limit
would
be
15
and
the
range
is
6.
because
you
are
choosing
from a
pool
of
6
numbers.
If
you're
choosing
numbers
from 2
to
100.
the
lower
limit
is
2
and
the
range
is
99.
Now
let's
try
out
a
program:
10
PRINT
INT(5"RND(1))
-
1
Type
RUN
and
press
return
RUN
the
program
a
few
times
Each
lime
you
run the
program,
you
get
a
random
number
from
1
to
5.
Now
let's
onnt
15
random
numbers,
with
the
lower
limit
1
and
the
range
5
note
that
all
15
numbers
chosen
are
selected
at
random
from
between
1
and
5
n.

Other manuals for Commodore Plus 4

Related product manuals