rendered paste body#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <stdafx.h>
int rollDice(void);
int actual [11] = {0};
int expected [11] = {1000,2000,3000,4000,5000,6000,5000,4000,3000,2000,1000};
int main(void) {
int rollValue=0;
srand( time ( NULL ) );
for (int x=0; x<36000; x++) {
rollValue = rollDice() + rollDice();
actual[rollValue-2]++;
}
printf("Sum\t\tTotal\t\tExpected\t\t Actual\n");
for (int x=0; x<11; x++) {
printf("%3d\t\t%5d\t\t%7.3f%%\t\t%6.3f%%\n",x+2,actual[x],((float) expected[x]/360),( (float) actual[x]/360) );
}
return 0;
}
int rollDice(void) {
return (1 + rand()%6);
}