All pastes #434740 Raw Edit

Something

public text v1 · immutable
·published 2007-04-11 16:01 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.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",x+2);
		printf("%5d\t\t",actual[x]);
		printf("%7.3f%%\t\t",((float) expected[x]/360));
		printf("%6.3f%%\n",( (float) actual[x]/360) );
    }

    return 0;
}

int rollDice(void) {
    
    return (1 + rand()%6);
}