Advertisement
aimzworld007

GPA CALCULATION FOR SSC & HSC

Oct 30th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int i,sub,marks,op,osub;
  6. float gp =0.0;
  7.  
  8. printf("\n ---GPA CALCULATION FOR SSC & HSC:---\n\n");
  9. printf("\nEnter the number of main subjects: ");
  10. scanf("%d",&sub);
  11.  
  12. for(i=1; i<=sub; i++)
  13. {
  14. printf("Enter %d No Subject marks: \n",i);
  15. scanf("%d",&marks);
  16. switch(marks/10)
  17. {
  18. case 10:
  19. case 9:
  20. case 8:printf("A+\n");gp=gp+5.0;break;
  21. case 7:printf("A\n");gp=gp+4.0;break;
  22. case 6: printf("A-\n");gp=gp+3.5; break;
  23. case 5: printf("B\n"); gp=gp+3.0; break;
  24. case 4: printf("C\n"); gp=gp+2.5; break;
  25. case 3: printf("D\n"); gp=gp+2.0; break;
  26. default: printf("F\n");
  27. }
  28. }
  29. printf("\nIf you have any optional Subject then Press :1 \nIf you have No optional Subject then Press :0\n\n");
  30. scanf("%d",&op);
  31. if(op==1)
  32. {
  33. printf("Enter the marks of Optional subjects: ");
  34. scanf("%d",&osub);
  35. switch(osub/10)
  36. {
  37. case 10:
  38. case 9:
  39. case 8:printf("A+\n");gp=gp+3.0;break;
  40. case 7:printf("A\n");gp=gp+2.0;break;
  41. case 6: printf("A-\n");gp=gp+1.5; break;
  42. case 5: printf("B\n"); gp=gp+1; break;
  43. case 4: printf("C\n"); gp=gp+.50; break;
  44. case 3: printf("D\n"); gp=gp+0.0; break;
  45. default: printf("F\n");
  46. }
  47. if(sub==5)
  48. {
  49. if(gp>25.0)
  50. {gp=25.0;
  51. printf("\n Your GPA= %.2f",gp/sub);
  52. }
  53. else
  54. printf("\n Your GPA= %.2f",gp/sub);
  55. }
  56. if(sub==8)
  57. {
  58. if(gp>40.0)
  59. {
  60. gp=40.0;
  61. printf("\n Your GPA= %.2f",gp/sub);
  62. }
  63. else
  64. printf("\n Your GPA= %.2f",gp/sub);
  65. }
  66. }
  67. else
  68. printf("\n Your GPA= %.2f",gp/sub);
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement