#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* function main begins program execution */
int main()
{
long i; /* counter */
int j; /* counter */
int x; /* 1st dice */
int y; /* 1nd dice */
int sum[ 13 ] = { 0 };
/* the dice will be rolled 36 times */
int expected[ 13 ] = { 0, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1};
srand ( time( NULL) ); /* random number */
for ( i = 1; i <= 3600; i++ ) {
x = 1 + rand() % 6;
y = 1+ rand() % 6;
++sum[ x + y };
}
printf( "%10s%10s%10s%10s\n", "Sum", "Total", "Expected", "Actual" );
/* shows actual rolling of dice */
for ( j = 2; j <= 12; j++ ) {
printf( "%10d%10d%9.3f%%%9.3f%%\n", j, sum[ j ], 100.0 * expected[ j ] / 36, 100.0 * sum[ j ] / 3600 );
} /* end for statement */
return 0; /* indicate program ended successfully */
} /* end main */
--------------
when I go to compile it I get this:
"fig619T.c", line 22.18: 1506-277 (S) Syntax error: possible missing ',' or ']'?
"fig619T.c", line 25.3: 1506-273 (E) Missing type in declaration of printf.
"fig619T.c", line 25.3: 1506-343 (S) Redeclaration of printf differs from previous declaration on line 263 of "/usr/include/stdio.h".
"fig619T.c", line 25.3: 1506-378 (I) Prototype for function printf cannot contain "..." when mixed with a nonprototype declaration.
and also, what line is line 25.3? where do I count from- the top?
thanks