The program should simulate rolling of 2 dice and add the sum of the 2 dice after they are rolled for 3600 times.
Their sum ranges from 2-12. The frequency should be tallied in this order
for eg when sum =2 freq =..
when sum =3 freq =..
etc
This is what I have attempted so far but the same frequency is outputted each time. There is some problem with the program and as i can recall it is from the random number generation but can't get to anywhere.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main ()
{
int num1,num2,i,j,freq[11]={0},total;
for (i=1;i<=36000;i++) {
srand(time(NULL));
num1=1+rand()%6;
srand(time(NULL));
num2=1+rand()%6;
total=num1+num2;
freq[total-2]++;
}
for(j=2;j<=12;j++)
{
printf("%d = %d\n",j,freq[i-2]);
}
fflush(stdin);
getchar();
return 0;
}