Question: Write a function that simulates the roll of a pair of dice. The function must generate two random numbers between 1 and 6, and return

Write a function that simulates the roll of a pair of dice. The function must generate two random numbers between 1 and 6, and return the sum of the numbers.

THIS IS WHAT I HAVE SO FAR - just needs fixing, do not change the entire code. I need the results to be added to each other in the output.

#include

using namespace std;

int rollDice (int number);

int main() { int roll1, roll2; int answer; roll1 = rand () % 6 + 1; cout << "The roll of the first die is equal to: " << roll1 << endl; roll2 = rand () % 6 + 1; cout << "The roll of the second die is equal to: " << roll2 << endl; answer = roll1 + roll2;

}

int rollDice (int number) { int answer; return answer; }

THE PROGRAM SHOULD SHOW THE RESULT OF EACH ROLL AND THEN THE SUM OF BOTH.

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!