rand Function

Generates a pseudo-random number.

Include

<stdlib.h>

Prototype

int rand(void);

Remarks

Successive calls to the rand function generates a pseudo-random number sequence, each number in the range 0 to RAND_MAX.

Example

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

int main(void)
{
  int value;

  value = rand();
  printf("Today's lucky number is %d\n", value);
}

Example Output

Today's lucky number is 8073