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

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)); cout
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