Random
Integer
rand/srand
Syntax
#include
<stdlib.h>
int
rand()
void
srand(seed)
unsigned
int
seed;
Defined
in
rand.
c in
rts.
src
Description
Two
functions
work
together
to
provide pseudo-random sequence gener-
ation:
• The
rand
function returns pseudo-random integers in the range
Q-RAN
D-MAX.
• The
srand
function sets the value
of
seed
so that a subsequent call
to
the rand function produces a
new
sequence
of
pseudo~random
numbers. The srand
function
does
not
return a value.
If
you call rand before calling srand, rand generates the same sequence
it
would
produce
if
you first called srand
with
a seed value
of
1. If you call
srand
with
the same seed value, rand generates the same sequence
of
numbers.
6-61