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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started