akosiraff

Download: Rand Medium C

Jan 30th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1.  
  2. Download: http://solutionzip.com/downloads/rand-medium-c/
  3. The Function rand() returns values in the interval [0. RAND_MAX] (see the previous exercise). If we declare the variable median and initialize it to have the value RAND_MAX/2, then the rand() returns a value that is sometimes larger than median and sometimes smaller. On average, however, there should be as many values that are larger as there are values that are smaller than the median. Test the hypothesis. Write a program that calls rand(), say 500 times inside a for loop, increments the variable plus_cnt every time rand() returns a value larger than median, and increments the variable minus_cnt every time rand() returns a value less than median. Each time through the for loop, print out the value of the difference of plus_cnt and minus_cnt. This difference should oscillate near zero.
  4. Download: http://solutionzip.com/downloads/rand-medium-c/
Add Comment
Please, Sign In to add comment