rand

compute a sequence of pseudo-random integers

Synopsis:

#include <stdlib.h>
int rand( void );

Description:

The rand() function computes a sequence of pseudo-random integers in the range 0 to RAND_MAX (32767). The sequence can be started at different values by calling the srand() function.

Returns:

a pseudo-random integer

See also:

srand()

Examples:

#include <stdio.h>
#include <stdlib.h>

void main()
  {
    int i;

    for( i=1; i < 10; ++i ) {
      printf( "%d\n", rand() );
    }
  }

Classification:

ANSI

Systems:

All (except DOS/PM)