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());
           }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster