The function rand() returns values in the interval


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.  

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: The function rand() returns values in the interval
Reference No:- TGS094198

Expected delivery within 24 Hours