Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- main(){
- double score, sum = 0, count = 0, passing = 0, passPercentage;
- printf("Enter a test score: (-1 to quit) \n");
- scanf("%lf", &score);
- count = count + 1;
- if(score >= 60 && score <= 100){
- passing = passing + 1;
- }
- if (score > 100 || score <= -2){
- printf("This is not a valid grade! \n");
- }
- while (score != -1) {
- printf("Enter a test score: (-1 to quit) \n");
- scanf("%lf", &score);
- count = count + 1;
- if(score >= 60 && score <= 100){
- passing = passing + 1;
- }
- }
- count = count - 1;
- passPercentage = passing / count * 100;
- printf(" \n Percentage of passing scores: %lf. \n", passPercentage);
- system("pause");
- }
Add Comment
Please, Sign In to add comment