average is correct but the sum is wrong. :)In case you still need the answer... Following main(), it looks like you go straight into a for()...
This user does not accept Private Messages