I need some help finishing this program. I'm in a beginner's C++ course, and I dont fully understand how to use arrays.
The program is to roll a single six-sided dice 6000 times to test whether the random number generator evenly distributes the random number it produces.
Each face 1,2,3,4,5,6 is cumulated in the array, frequency.
The output should be similar to this:
Code:
Face Frequency
1 964
2 1013
3 1023
4 995
5 997
6 1008
Here is what I have so far:
Code:
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
int num;
const int SIZE = 7;
int frequency[SIZE] = {0};
srand(time(0));
for (int i=0; i<6000; i++) //loop for rolling 6000 times
{
num = 1+rand()%6;
++ frequency[num];
}
cout <<"Face"<<setw(13) <<"Frequency"<<endl;
//print out the results
return 0;
}
What am I missing?
Thanks in advance.