rand

Returns pseudorandom numbers in the range 0 to 2[31] - 1.

Format

#include  <math.h>

int rand  (void);

Description

This function uses the following ANSI Standard algorithm to return a random number:
static unsigned int next = 1;
int rand(void)
{
       next = next * 1103515245 + 12345;
       return (next  & RAND_MAX);
}

See also srand in this section.

For other random number algorithms, see random and all the *48 functions.


Previous Page | Next Page | Table of Contents | Index