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

Step 1: Complete the code below and use it for main(). int main() { srand(time(0

ID: 646032 • Letter: S

Question

Step 1: Complete the code below and use it for main().
int main() {
srand(time(0));
int first=0, last=9;
for (int r = 1; ________; r+=10) {
cout<<"The range for this row is: "<<_________<<" to "<<________<<": ";
for(int c = 1; __________; c++) {
cout<<randNum(first+r,last+r)<<" ";
}
cout<<endl;
}
cout << endl;

return 0;
}


Step 2: Above int main() add the proper header (such as #include libraries) and write
the function randNum, so that the output when the program runs is similar to the following:
The range for this row is: 1 to 10: 10
The range for this row is: 11 to 20: 17 14
The range for this row is: 21 to 30: 22 29 22
The range for this row is: 31 to 40: 40 34 34 38
The range for this row is: 41 to 50: 50 50 45 41 47
The range for this row is: 51 to 60: 51 58 58 56 51 57
The range for this row is: 61 to 70: 68 62 62 66 62 61 69
The range for this row is: 71 to 80: 75 71 77 76 79 73 77 78
The range for this row is: 81 to 90: 84 86 83 90 86 82 89 82 84
The range for this row is: 91 to 100: 98 92 93 97 99 93 93 98 94 94

Note: The numbers are randomly generated so they should be different each time, but they should be in the specified range.

Explanation / Answer

#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

int randNum(int f, int l){
   return (rand() % (l - f + 1)) + f;
}

int main() {
   srand(time(0));
   int first=0, last=9;
   for (int r = 1; r < 100; r+=10) {
       cout<<"The range for this row is: "<< r <<" to "<< (r + 9) <<": ";
       for(int c = 1; c <= (r / 10) + 1 ; c++) {
           cout<<randNum(first+r,last+r)<<" ";
       }
       cout<<endl;
   }
   cout << endl;

   return 0;
}

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