/* From: "COMPUTATIONAL PHYSICS, 2nd Ed" by RH Landau, MJ Paez, and CC Bordeianu Copyright Wiley-VCH, 2007. Electronic Materials copyright: R Landau, Oregon State Univ, 2007; MJ Paez, Univ Antioquia, 2007; & CC Bordeianu, Univ Bucharest, 2007 Support by National Science Foundation */ // call.c: Creates pseudo-random numbers using drand48 or rand #include #include #include // if you don't have drand48 uncomment the following two lines // #define drand48 1.0/RAND_MAX*rand // #define srand48 srand main() { int i, seed; double x; printf("enter seed\n"); // user plants seed scanf("%i", &seed); srand48(seed); // seed drand 48 for (i=1; i<=10; i++) { x = drand48(); // random number between 0 and 1 printf("Your random number is: %f\n",x); } }