rand() — Generate random number

Format

#include <stdlib.h>

int rand(void);

General Description

The rand() function generates a pseudo-random integer in the range 0 to RAND_MAX. Use the srand() function before calling rand() to set a seed for the random number generator. If you do not make a call to srand(), the default seed is 1.
Note: Use of this function requires that an environment has been set up by using the __cinit() function. When the function is called, GPR 12 must contain the environment token created by the __cinit() call.

Returned Value

The rand() function returns the calculated value.

Related Information