Chapter21ex1.c 442 B

123456789101112131415161718192021222324252627
  1. #include <stdio.h>
  2. main()
  3. {
  4. int gameScores[10] = {12, 5, 21, 15, 32, 10};
  5. int totalPoints = 0;
  6. int i;
  7. float avg;
  8. for (i=6; i < 10; i++)
  9. {
  10. printf("What did the player score in game %d? ", i+1);
  11. scanf(" %d", &gameScores[i]);
  12. }
  13. for (i=0; i < 10; i++)
  14. {
  15. totalPoints += gameScores[i];
  16. }
  17. avg = ((float)totalPoints / 10);
  18. printf("\n\nThe Player's scoring average is %.1f.\n", avg);
  19. return(0);
  20. }