Advertisement
joyshree94

gpa

Jan 21st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include<stdio.h>
  2. void main()
  3. {
  4. int i,a[5],j;
  5. float GPA=0.00,avrg;
  6. for(i=0;i<5;i++)
  7. {
  8. scanf("%d",&a[i]);
  9. if(a[i]<33)
  10. printf("F");
  11. {
  12. j=a[i]/10;
  13. switch(j)
  14. {
  15. case 3:printf("D\n");
  16. GPA=+1.00;
  17. break;
  18. case 4:printf("C\n");
  19. GPA=GPA+2.00;
  20. break;
  21. case 5:printf("B\n");
  22. GPA=GPA+3.00;
  23. break;
  24. case 6:printf("A-\n");
  25. GPA=GPA+3.50;
  26. break;
  27. case 7:printf("A\n");
  28. GPA=GPA+4.00;
  29. break;
  30. case 8:
  31. case 9:
  32. case 10:printf("A+\n");
  33. GPA=GPA+5.00;
  34. break;
  35. defalt:printf("ERROR");
  36. }
  37. }
  38. }
  39.  
  40. avrg=GPA/5;
  41.  
  42. printf("\nAverage is %f\n",avrg);
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement