Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a function getRandomNum(int min, int max) that takes two arguments, a

ID: 3797043 • Letter: I

Question

Implement a function getRandomNum(int min, int max) that takes two arguments, a min and a max integer. The function returns an integer which is a random number between minimum (including minimum) and maximum (excluding maximum).

Ask the user to enter four integers and call the function twice. Multiply the result together and print out the result to the screen.

You can assume the seed is set to the integer 1.

Template for input/output

Enter first minimum number: < input integer1>

Enter first maximum number: < input integer2>

Enter second minimum number: < input integer3>

Enter second maximum number: < input integer4>

< random number 1> * < random number 2> = < result>

Sample input/output (bolded is input, which do not show up on ZyBooks)

Enter first minimum number: 0

Enter first maximum number: 6

Enter second minimum number: 0

Enter second maximum number: 6

1 * 4 = 4

My output keeps coming out wrong? Need help here

include kiostream 2 #include 3 #include 4 using namespace std. 5 int getRandomNum (int min, int max) 6 int getRandomNum (int min, int max) int seedVal 10 time t t 12 seedVal (unsigned) time (&t;) 13 grand (seed Val) 14 15 16 return rand max+min; 17 18 int main 19 20 21 int mln. fmax, smin smax, random number 1 r random number2 22 23 24 Coutfmin; 26 27 28 Coutfmax; 30 31 32 random number 1XgetRandomNum (fmin fmax) 33 34 35 Cout

Explanation / Answer

Change the getRandomNum().

int getRandomNum(int min, int max){

  
   int seedVal = 0;
  
   time_t t;
  
   seedVal = (unsigned) time(&t);
   srand(seedVal);

return min + rand()%(max-min+1); // This line was wrong.

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote