Question: solve C++ and use/copy rand_int function attached above. y = rand ( )%51-25; This statement first generates a value between 0 and 50, and then

 solve C++ and use/copy rand_int function attached above. y = rand solve C++ and use/copy rand_int function attached above.

y = rand ( )%51-25; This statement first generates a value between 0 and 50, and then subtracts 25 from the value yielding a new value between -25 and 25 We can now write a function that generates an integer between two specified integers, a and b. The function first computes n, which is the number of all integers between a and b, inclusive, this value is equal to b-a + 1. The function then uses the modulus operation with the rand () function to generate a new integer between 0 and n 1. Finally, the lower limit, a, is added to the new integer to give a value between a and b. All three steps can be combined in one expression on the return statement in the function: / This function generates a random integer /* between specified limits a and b (a //Required for srand ( ), rand() #include > seed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!