Question: The code below should allow a user to enter a number for the number of sides of a die. It should then generate a random

The code below should allow a user to enter a number for the number of sides of a die. It should then generate a random number that was rolled on that die. I have stubbed out most of the code. Your job is to complete it.

/* This program allows a user to roll a die of any size. */ #include  using namespace std; int main() { int numberOfSides = 0; do { cout << "How many sides do you want the die to have? "; cin >> numberOfSides; if (numberOfSides <= 0) { cout << "Error: Please enter a positive integer!" << endl << endl; } } while (numberOfSides <= 0); int result = rollDie(numberOfSides); cout << "You rolled a " << result << endl; } int rollDie(int numberOfSides) { // Complete this function }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!