Requirements 1 Create a function that simulates a throw of t
Solution
//Include libraries
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
/*Function prototype*/
int twoDice();
//Define a main method
int main()
{
//Declare arrays
int sum[100], a[100], b[100];
//Call twoDice() to get first number
int A = twoDice();
//Call twoDice() to get second number
int B = twoDice();
//Compute sum
int C = A + B;
//Display values
cout<<\"A = \"<<A<<\" \"<<\"B = \"<<B<<\" \"<<\"Sum is \"<<C<<endl;
//Loop until 100
for(int li=0;li<100;li++)
{
//Call twoDice() to get first number and store in array
a[li] = twoDice();
//Call twoDice() to get second number and store in array
b[li] = twoDice();
//Store sum in array
sum[li] = a[li]+b[li];
}
//Set heading
cout<<\"a\"<<setw(8)<<\"b\"<<setw(25)<<\"sum\"<<endl;
//Loop until 100
for(int li=0;li<100;li++)
{
//Dsiplay values
cout<<a[li]<<setw(8)<<b[li]<<setw(25)<<sum[li]<<endl;
}
//Pause console window
system(\"pause\");
//Return 0
return 0;
}
//Define function twoDice()
int twoDice()
{
//Call rand() function.
int num1 = rand() % 6 + 1;
//Return number
return num1;
}
Sample Output:
A = 6 B = 6 Sum is 12
a b sum
5 5 10
6 5 11
1 1 2
5 3 8
6 6 12
2 4 6
2 6 8
2 3 5
4 1 5
4 1 5
3 4 7
5 5 10
4 3 7
3 6 9
6 1 7
6 1 7
4 5 9
6 2 8
2 1 3
6 4 10
3 4 7
4 3 7
4 2 6
6 5 11
6 3 9
5 4 9
4 2 6
6 4 10
2 5 7
5 6 11
3 1 4
1 5 6
5 3 8
5 5 10
3 4 7
3 4 7
5 3 8
1 4 5
4 3 7
4 6 10
1 5 6
1 3 4
5 3 8
6 5 11
1 4 5
3 2 5
6 5 11
3 1 4
4 6 10
4 6 10
2 1 3
1 1 2
4 3 7
6 1 7
6 6 12
3 5 8
1 4 5
6 4 10
4 1 5
5 1 6
6 1 7
6 6 12
4 5 9
6 5 11
3 5 8
4 5 9
5 5 10
4 6 10
2 4 6
2 6 8
4 4 8
6 6 12
2 3 5
6 1 7
3 5 8
3 5 8
4 3 7
1 6 7
1 6 7
5 6 11
1 6 7
3 4 7
2 4 6
3 3 6
2 3 5
3 5 8
1 4 5
1 4 5
1 5 6
2 1 3
6 2 8
1 3 4
1 3 4
2 6 8
3 2 5
1 2 3
6 4 10
1 6 7
2 5 7
6 3 9
Press any key to continue . . .




