I wrote a program (with some help from a C++ book) to roll a6-sided dice. I was
ID: 3612754 • Letter: I
Question
I wrote a program (with some help from a C++ book) to roll a6-sided dice. I was trying to alter the program to allow meto choose the number of sides on the die (ie, 6, 8, 10, etc) andhow many times it would be rolled (ie 1, 2, 3), but I had noluck. Below is what I wrote for a single 6-sided. Ineed help in altering it.// Die Roller
// Demonstrates generating random numbers
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(0)); // seed randomnumber generator based on current time
int randomNumber = rand(); //generaterandom number
int die = (randomNumber % 6) +1; // get a numberbetween 1 and 6
cout << "You rolled a " << die<< endl;
system("pause");
return 0;
}
Explanation / Answer
please rate - thanks // Die Roller // Demonstrates generating random numbers #include #include #include using namespace std; int main() {int sides,rolls,randomNumber,i; coutsides; coutrolls; srand(time(0)); // seed randomnumber generator based on current time for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.