Hi guys,

I'm new in programming and I just started to learn C language. I got this assignment question that requires me to use random number generation. I know how to create a simple random number generation using seed. But this question is giving me a headache. Please spare me some advice.

Write a C program to perform the following task:

Consider P fair dices where each dice is a tetrahedron. The four sides of the i-th dice are numbered 3i, 3i-1, 3i-2, and 0 (blank), respectively, as shown below:

```
Dice 1: {1, 2, 3, 0}
Dice 2: {4, 5, 6, 0}
Dice 3: {7. 8. 9. 0}
Dice P: {3P-2, 3P-1, 3P, 0}
```

At each throw, the sum of the numbers on the downward face of each dice is calculated and recorded. By using a random number generator, simulate the result (the faces that have been chosen) for N throws (e.g. 1000000).

From the statistics obtained, determine the number of ways to form all possible sum. For instance, if we try to find the number of combinations with pen and paper, say for P = 4, there are 4 ways to form the sum = 10 as given below:

```
Dice 1 Dice 2 Dice 3 Dice 4 Sum
0 + 0 + 0 + 10 = 10
1 + 0 + 9 + 0 = 10
2 + 0 + 8 + 0 = 10
3 + 0 + 7 + 0 = 10
```

Your program should be able to read in 2 variables – i.e. number of throws (N), and number of dices (P). On the output screen, the frequency of getting each sum (Hint: the maximum sum of P dices is 3/2*P*(P+1)), and number of combinations to form the sum (Hint: number of combinations = Freq*(4 power of P)/N) should be displayed. A sample output is given as follows:

```
Enter number of throws : 1000000
Enter number of dices : 4
Sum : Freq : Number of combinations
0 3933 1
1 3882 1
2 3907 1
3 3895 1
4 3891 1
5 7851 2
6 11712 3
7 15644 4
8 15648 4
9 15682 4
10 15568 4
: : :
: : :
30 3932 1
```

Hope someone can help with this. :sad: