[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
rand() Get Pseudorandom Integer
#include <stdlib.h> Required for declarations only
int rand(void);
rand() returns a pseudorandom integer in the range 0-32767. srand()
can be used before calling rand() to set a random starting point.
Returns: A pseudorandom number in the range 0 to 32767 (maximum
integer size). There is no error return.
-------------------------------- Example ---------------------------------
The following statements generate 10 random numbers in the range 0 to
32767 and print them out.
#include <stdlib.h>
#include <stdio.h>
int i;
main()
{
printf(" RANDOM NUMBERS \n");
for (i = 1; i <= 10; i++)
printf("index: %d, random number: %d \n",i,rand());
}
See Also:
srand()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson