Goals Practicing reference parameters and generating random
Goals: Practicing reference parameters and generating random numbers
For this lab you should write a program that contains a main function and one additional function (to generate random numbers and determine if the random number is equal to, below or above a given number). Your main function should prompt the user to enter a whole number between 0 and 100 not including 0 and 100 hundred. (You may assume the user enters a valid number or check it within main as practice). Your main should then call the function. After the function has completed, your main function should output how many of the generated numbers were equal to the entered value, how many of the generated numbers were less than the entered value, and how many of the generated numbers were greater than the entered value.
Your function should use a loop to generate 100 random numbers between 0 and 100 including 0 and 100, then count how many of the generated numbers were equal to the entered value, how many were less than the entered value, and how many were greater than the entered value. (Review pages 127 – 129 of your text book for random number generation. Your function should send how many were equal to, less than, and greater than the entered value back to the function call in main.
Solution
Please find the required program along with its output. Please see the comments against each line to understand the step.
------------------------------------------------------------
OUTPUT:
Enter a number between 0-100 (excluding 0 & 100) :
23
Random numbers generated more than 23 is : 82
Random numbers generated less than 23 is : 17
Random numbers generated equal to 23 is : 1
