home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_06 / 1n06046b < prev    next >
Text File  |  1990-09-30  |  548b  |  22 lines

  1.  
  2. Listing 3: the C program
  3.  
  4.  
  5. /* program to return random value                     */
  6.  
  7. /* random(n,0) returns next random value in sequence  */
  8. /* random(n,s) resets random sequence with new seed s */
  9.  
  10. pascal random (int size, int seed)
  11.  
  12.   {
  13.   int i;                        /* define space for integer */
  14.  
  15.   if (seed != 0) srand(seed);   /* if seed not equal to 0 then restart */
  16.                                 /* pseudo random sequence */
  17.   return(rand() % size);        /* return random number within range of size */
  18.  
  19.   }
  20.  
  21.  
  22.