EasyManua.ls Logo

Sharp PC-1500 - Random

Sharp PC-1500
169 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...
A
ll
and more about Sharp P
C-
1500 at http://www.PC-1500.info
C.9.
RANDOM
Random
numbe
rs arc
generated
by
a
mathema
tical
formula
and
are
acc
-cssi
ble
by using
the
RND
functio
n.
\"v'henever
the compu
te'
is
turned
ON,
a series
of
random numbers is
ge
nerated
by
the computer. This list remains unchanged u"less the
RANDOM
func
ti
on is used. This means
that
a progr<lm w;
11
use
the
same
series
of
"random"
numbe
rs
each
time
the
compu
t
er
is
turned
on.
To
prevent
this.
the
RANDOM
function
resets the
"seed"
used
by
the
fo
r
mula
to
gencrotc
its
random
numbers.
Example 1: Example 2:
10
FOR
I = 1
TO 5 10 FOR I = 1 TO 5
15
A =
RND
3
15
A =
RND
3
20
PR
INT
A;
20
PRIN
T A;
30
NEXT
30
NE
XT
Output
: , 2
23
1
Output:
12231
To
get true
random
nu
mb
e
rs
in t
his
case
the
fu
nc
ti
on
RA
NDOM shou
ld
appear
before
t
he
AND
statement
.
Th
is fun
ctio
n sovvs a n
ew
seed in the generation
of
random
numbers
and
thus
causes
the num bers
to
differ.
Accord
in
gly,
a pr
ogram
r
un
under
i
dent
ic
al
condit
i
ons
will
prod
uce
va
ri
ed
output'
:
Exarn1>lc
I:
Example
2:
10
RA
NDOM
10
RANDOM
15
FOR
I = 1 TO 5 15 FOR I = 1 TO
5
20 A =
RND
3
20
A =
RND
3
30
PR
I
NT
A;
30
PR
INT
A;
40
NEX
T
40
N
EXT
Output:
31223
Ou
tput:
23132
C
.1
0. STRS
STAS
v:orks in a
manner
o
ppo
si
te
to
VAL
. It '.
viii
con
ve
rt
an
interna
l n
ume
ri
c vari
ab
le back
to
its
charac
t
er
String r
epresentat
i
on
.
1<>
INPUT
"E
NTER
A NUMBE
A";
20
SS
= ST
RS
(I)
30
PA
U
SE
"THAT
NUMBER
IS
..
40
PRINT
"THE
ST
RING
.. ;
SS
The above
prog
r
am
accept
s a f'IUmber.
fo
rms
the
cha
racter
re
1)
resentat
ion
of
th
at
number
and
st
ores
it in t
he
cha
ra
cter
v-0riablc SS. Because t
he
interna
l nu
n1e
ri
c r
epresentation
cannot
be
di
splayed
it is " ut
omat
i
ca
ll
y
conv
e
rted
back into a
charac
ter string
by
the
PR
INT statenlent.
78
Do
not sale this PDF
!!!

Table of Contents

Other manuals for Sharp PC-1500

Related product manuals