#### Details of this Paper

##### Write a program that does the same thing with adding up 2 6-sided

Description

solution

Question

Fig 7.10 page 278 shows a program simulating rolling 6,000,000 times a 6-sided die.;Write a program that does the same thing with adding up 2 6-sided dice first (totals are between 2 and 12), and then adding up 3 4-sided dice (totals are between 3 and 12).;1 // Roll a six-sided die 6,000,000 times.;2 #include;3 #include;4 #include;5 #include;6 using namespace std;7;8 int main();9;10 const int arraySize = 7, // ignore element zero;11 int frequency[ arraySize ] = {}, // initialize elements to 0;12;13 srand(time(0)), // seed random number generator;14;15 // roll die 6,000,000 times, use die value as frequency index;16 for (int roll = 1, roll <= 6000000, ++roll);17 ++frequency[ 1 + rand() % 6 ];18;19 cout << "Face" << setw(13) << "Frequency" << endl;20;21 // output each array element's value;22 for (int face = 1, face < arraySize, ++face);23 cout << setw(4) << face << setw(13) << frequency[ face ];24 << endl;25 } // end main

Paper#68874 | Written in 18-Jul-2015

Price : \$32