Advertisement
Mahmud33

percentage

May 25th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int p, ch, b, m, c;
  5.     float ptg;
  6.  
  7.     printf("Physics: ");
  8.     scanf("%d", &p);
  9.     printf("Chemistry: ");
  10.     scanf("%d", &ch);
  11.     printf("Biology: ");
  12.     scanf("%d", &b);
  13.     printf("Math: ");
  14.     scanf("%d", &m);
  15.     printf("Computer: ");
  16.     scanf("%d", &c);
  17.  
  18.     ptg = ((p+c+b+m+c)/500.0)*100;
  19.     printf("Percentage: %0.2f%%  \n", ptg);
  20.  
  21.     if(ptg >= 90)
  22.     {
  23.         printf("Grade: A \n");
  24.     }
  25.     else if(ptg >= 80)
  26.     {
  27.         printf("Grade: B");
  28.     }
  29.     else if(ptg >= 70)
  30.     {
  31.         printf("Grade: C");
  32.     }
  33.     else if(ptg >= 60)
  34.     {
  35.         printf("Grade: D");
  36.     }
  37.     else if(ptg >= 40)
  38.     {
  39.         printf("Grade: E");
  40.     }
  41.     else if(ptg < 40)
  42.     {
  43.         printf("Grade: F");
  44.     }
  45.  
  46.     return 0;
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement