daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2018 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. main(){
  5.  
  6.     double score, sum = 0, count = 0, passing = 0, passPercentage;
  7.  
  8.     printf("Enter a test score: (-1 to quit) \n");
  9.     scanf("%lf", &score);
  10.     count = count + 1;
  11.     if(score >= 60 && score <= 100){
  12.             passing = passing + 1;
  13.         }
  14.  
  15.     if (score > 100 || score <= -2){
  16.         printf("This is not a valid grade! \n");
  17.  
  18.     }
  19.        
  20.     while (score != -1) {
  21.         printf("Enter a test score: (-1 to quit) \n");
  22.         scanf("%lf", &score);
  23.  
  24.         count = count + 1;
  25.  
  26.         if(score >= 60 && score <= 100){
  27.             passing = passing + 1;
  28.         }
  29.     }
  30.  
  31.     count = count - 1;
  32.  
  33.     passPercentage = passing / count * 100;
  34.  
  35.     printf(" \n Percentage of passing scores: %lf. \n", passPercentage);
  36.  
  37.     system("pause");
  38.  
  39. }
RAW Paste Data
Top