rand, srand
Purpose
Generates pseudo-random numbers.
Library
Standard C Library (libc.a)
Syntax
int rand ( ) void srand (seed);
unsigned int seed;
Description
The rand subroutine generates a random numbers using a
multiplicative congruential algorithm. The random-number
generator has a period of 2(32), and it returns succes-
sive pseudo-random numbers in the range from 0 to
2(15) - 1.
The srand subroutine resets the random-number generator
to a random starting point. The generator is initially
seeded with a value of 1.
Note: The rand subroutine is a very simple random-number
generator. Its spectral properties, the mathematical
measurement of how "random" the number sequence is, are
somewhat weak. See "drand48" for a more elaborate
random-number generator that has better spectral proper-
ties.