Calling a Built-In Generator in C

 
#include <stdio.h>
#include <math.h>

main()
{
   int i, seed;
   double x;
   
   printf("enter seed\n");	/* user plants seed */
   scanf("%i", &seed);
   srand48(seed);
   
   for (i=1; i<20; i++) 
   {
      x = drand48();		/* random number between 0 and 1 */
      printf("%f\n",x);
   }
}

NOTICE: This is the drand48 function, available on the DEC-system. This is not a standard C function.
Back to main document.