Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- float average, score_amount, i, score_total;
- score_amount = 0;
- score_total = 0;
- printf("The program calculates the average of scores you enter.\n");
- printf("End with a negative integer.\n");
- do
- {
- printf("Enter score (4-10):");
- scanf("%f", &i);
- score_total = score_total + i;
- score_amount = score_amount + 1;
- if(i < 0)
- {
- score_amount = score_amount -1;
- score_total = score_total - i;
- average = score_total / score_amount;
- printf("You entered %.0f scores.\n", score_amount);
- printf("Average score: %.2f", average);
- }
- }
- while(i >= 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement