another code problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

another code problem

Panasonic99Panasonic99 Posts: 140Member
#include
#include
#include

/* 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
", "Sum", "Total", "Expected", "Actual" );

/* shows actual rolling of dice */
for ( j = 2; j <= 12; j++ ) {
printf( "%10d%10d%9.3f%%%9.3f%%
", 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

Comments

  • pseudocoderpseudocoder Posts: 691Member ✭✭✭
    : ++sum[ x + y };[blue] <-- needs a closing ] not the }. It's *probably* the source of the other errors.[/blue]
    : }

    :
    : and also, what line is line 25.3? where do I count from- the top?
    : thanks

    [blue]Yep... dunno what the floating point value indicates though. :)[/blue]
    :
  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : : ++sum[ x + y };[blue] <-- needs a closing ] not the }. It's *probably* the source of the other errors.[/blue]
    : : }
    :
    : :
    : : and also, what line is line 25.3? where do I count from- the top?
    : : thanks
    :
    : [blue]Yep... dunno what the floating point value indicates though. :)[/blue]
    : :
    :

    Most likely character 3.

    Greets...
    Richard

Sign In or Register to comment.