Generate a pseudo-random integer.
The rand() function returns a pseudo-random integer in the range 0 to RAND_MAX (at least 32767). The sequence of pseudo-random numbers generated depends on the seed set by srand().
If srand() has not been called, rand() behaves as if srand(1) had been called. Calling srand() with the same seed value will produce the same sequence of random numbers, which is useful for reproducible testing.
For generating numbers in a specific range, use the modulo operator, though this may introduce slight bias. For cryptographic purposes, use a proper random number generator instead. It is declared in <stdlib.h>.
int r = rand() % 100; /* Random number between 0 and 99 */