Question
Hi! I have a C++ task where I have the following template, where the lower and upper limits are read, from which the random numbers
Hi!
I have a C++ task where I have the following template, where the lower and upper limits are read, from which the random numbers are generated. In addition, it checks that the lower limit is genuinely lower than the upper limit.
#include #include #include
using namespace std;
void produce_random_numbers(unsigned int lower, unsigned int upper) { // Implement your function here }
int main() { unsigned int lower_bound, upper_bound; cout cin >> lower_bound; cout cin >> upper_bound;
if(lower_bound >= upper_bound) { cout
return EXIT_FAILURE; }
produce_random_numbers(lower_bound, upper_bound);
return EXIT_SUCCESS; } |
The task is to implement the function produce_random_numbers, which produces random numbers for the given interval until the user gives the stop command q. There was also a hint: "The commands given by the user (c and q) should be read with the operator >>, because the lower and upper limits are also read with this operator. (In the same program, it is not recommended to read inputs with both the function getline and the operator >>, at least not in order: first >> and then getline."
The program is supposed to work as follows:
Thank you!
Enter a lower bound: 1 Enter an upper bound: 10 Enter a seed value: 1 Your drawn random number is 1 Press q to quit or any other key to continue: c Your drawn random number is 2 Press q to quit or any other key to continue: c Your drawn random number is 8 Press q to quit or any other key to continue: c Your drawn random number is 5 Press q to quit or any other key to continue: c Your drawn random number is 6 Press q to quit or any other key to continue: c Your drawn random number is 3 Press q to quit or any other key to continue: c Your drawn random number is 1 Press q to quit or any other key to continueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started