rand()
returns RAND_MAX[M-7] Write a main() program that generates
N*RAND_MAX random integers.
A uniform distribution is when each number is equally likely to occur.
If the output of rand()
is a uniform distribution then RAND_MAX should occur approximately
N times. Sample output:
RAND_MAX occured 1012 times in 1000*RAND_MAX trials
In this run of the program, rand() appears to be working correctly
since you would expect RAND_MAX to occur about 1000 times in 1000*RAND_MAX trials.
Caution: if your C environment uses a large RAND_MAX (such does gcc), you might want to limit the number of trials to 10*RAND_MAX .