Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago

Question

Were the right people involved in the decision-making process?

Answered: 1 week ago