Pseudorandom number sequence generation
[Classification]
Standard library
[Syntax]
#include <stdlib.h>
int rand(void);
[Return value]
Random numbers are returned.
[Description]
This function returns a random number that is greater than or equal to zero and less than or equal to RAND_MAX.
[Example]
#include <stdlib.h>
void func(void) {
if((rand() & 0xF) < 4)
func1(); /*execute func1 with a probability of 25%*/
}
|