Question: The expression double(rand()) / RAND_MAX produces a double-precision random number between 0.0 and 1.0. Scaling a random number as an integer value between 0 and
The expression double(rand()) / RAND_MAX produces a double-precision random number between 0.0 and 1.0. Scaling a random number as an integer value between 0 and N is done with the expression rand() % (N+1) or int (double(rand())/RAND_MAX * N). For example, the expression int (double(rand())/RAND_MAX * 100) produces a random integer between 0 and 100. To produce a random integer between 1 and N, you can use the expression 1 + rand() % N. The more general scaling expression a + rand() % (b + 1 a) can be used to produce a random integer between the number a and b. Based on the information above, and post solutions for the following questions 1- 6: 5. Write an expression that creates a double-precision random number in the range of 0.0 through 500.0.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
