SHARE
TWEET

C GUB Grading using Switch Case

naeem043 May 26th, 2018 (edited) 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n;
  6.     scanf("%d",&n,printf("Enter your marks:\t"));
  7.  
  8.     float m = (float)n/10;
  9.     switch(n/10)
  10.     {
  11.  
  12.         case 8:
  13.         case 9:
  14.         case 10:
  15.             if(n<=100) printf("A+\n");
  16.             break;
  17.         case 7:
  18.             if(m>=7.5 && m<8) printf("A\n");
  19.             else printf("A-\n");
  20.             break;
  21.         case 6:
  22.             if(m>=6.5 && m<7) printf("B+\n");
  23.             else printf("B\n");
  24.             break;
  25.         case 5:
  26.             if(m>=5.5 && m<6) printf("B-\n");
  27.             else printf("C+\n");
  28.             break;
  29.         case 4:
  30.             if(m>=4.5 && m<5) printf("C\n");
  31.             else printf("D\n");
  32.             break;
  33.  
  34.         default :
  35.             printf("F\n");
  36.             break;
  37.     }
  38.  
  39.     main();
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top