rand(), srand() - system random number generator
#include <stdlib.h>
void srand (unsigned seed)
int rand (void)
The rand(3) function computes a sequence of pseudo-random integers in the range of 0 to {RAND_MAX} (as defined in the header file <stdlib.h>).
The srand(3) function sets its argument as the seed for a new sequence of pseudo-random numbers to be returned by rand(3). These sequences are repeatable by calling srand(3) with the same seed value.
If no seed value is provided, the functions are automatically seeded with a value of 1.
To seed the random number generator with the time (a popular source), you can use:
srand((unsigned int)timer(NULL));
random(3)