To add to what Richard has said, the
inf
problem is pretty obvious. Look at your output:
Round 0 score: 95/100
...
Average score:inf
Look at the code that generates it:
printf(" Round %d score: %d/100\n", rounds, g); ...
printf(" Average score: %f\n", avg);
So we know that
rounds
is zero.
Look at the code to generate
avg
:
avg = allScore / rounds;
And you immediately see the source of the
inf
value: division by zero.
To be honest, thirty seconds with the debugger would have shown you that!