Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
rand, srand - pseudo-random number generator (int)
&pagelevel(4)&pagelevel
Syntax | #include <stdlib.h> int rand(void); void srand(unsigned int seed); |
Description | rand() returns a positive random integer in the range [0, 215-1]. A rand call selects values from a series of pseudo-random numbers by using a multiplicative, congruent random-number generator. The generator has a period of 232.
rand() is not thread-safe. Use the reentrant function rand_r() when needed.
|
Return val. | Random number in the range [0, 215-1] if successful. |
Notes | The random-number generator can be initialized or reset with srand() . If no initialization takes place, the random-number generator starts with its default value. |
See also | drand48() , rand_r() , random() , srand() , stdlib.h .
|