Write a function that simulates the roll of a pair of dice. The function must ge
ID: 3905283 • Letter: W
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 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<iostream>
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;
}
Explanation / Answer
#include #include #include using namespace std; int rollDice(int number); int main() { srand(time(NULL)); coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.