Hello,
I trying to write a program using the probability function to create 2 files. One of them will generate 100 random numbers and the other a 1000. The average is supposed to be 0.5.
This is what I have so far.
Am I going in the right direction? Any help will be appreciated.Code:#include <sdtio.h> #include <math.h> #define INITIAL_SEED 17 #define MULTIPLIER 25173 #define INCREMENT 13849 #define MODULUS 65536 #define FLOATING_MODULUS 65536.0 static unsigned seed = INITIAL_SEED; unsigned random(void) { seed = (MULTIPLIER * seed + INCREMENT) % MODULUS; return seed; } double probability(void) { seed = (MULTIPLIER * seed + INCREMENT) % MODULUS; return (seed / FLOATING_MODULUS); }



LinkBack URL
About LinkBacks


