random
raw OCR
Random number generator.
Defined in header <stdlib.h>
Syntax
#include <stdlib.h>
int random(int niim);
random returns a random number between 0 and (num-1). random(num)
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
is a macro defined in stdlib.h. Both num and the random number returned are integers.
Return value
random returns a number between 0 and (num-l).
See also
Example
include <stdlib.h>
#include <stdio.h>
#include <time.h>
int mainO /* prints a random number in the range 0 to 99 */
{
randomized ;
printf("Random number in the 0-99 range: %d\n", random (100));
return 0;
}
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdlib.h/random/
· short form /3.1/random/