Facebook
From Sole Giraffe, 3 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 46
  1. #include <stdio.h>
  2. int main(){
  3.  
  4. int total_ch=0;
  5. int total_courses=0;
  6. float sum=0.0;
  7. float gpa=0.0;
  8. printf("Enter total number of courses: \n);
  9. scanf(" %d",&total_courses);
  10.  
  11.  
  12.  
  13.  
  14. for(int i=0;i < total_courses; i++){
  15. char course[10];
  16. int marks=0;
  17. int ch=0;
  18. float cgpa=0.0;
  19. printf("Enter the course name: \n");
  20. scanf(" %s",&course);
  21. printf("Enter the credit hours of the course\n");
  22. scanf(" %d",&ch);
  23. printf("Enter the marks of the course\n");
  24. scanf(" %d",&marks);
  25. total_ch += ch;
  26. if (marks > 85){
  27. printf("Your Cgpa of %s is 4.00 and your grade is A\n",&course);
  28. sum+=(ch*4.00);
  29. }else if (marks > 79 && marks < 86 ){
  30. printf("Your Cgpa of %s is 3.67 and your grade is A-\n",&course);
  31. sum+=(ch*3.67);
  32. }else if (marks > 75 && marks < 80){
  33. printf("Your Cgpa of %s is 3.33 and your grade is B+\n",&course);
  34. sum+=(ch*3.33);
  35. }else if (marks > 71 && marks < 76){
  36. printf("Your Cgpa of %s is 3.00 and your grade is B\n",&course);
  37. sum+=(ch*3.00);
  38. }else if (marks > 67 && marks < 72){
  39. printf("Your Cgpa of %s is 2.67 and your grade is B-\n",&course);
  40. sum+=(ch*2.67);
  41. }else if (marks > 63 && marks < 68){
  42. printf("Your Cgpa of %s is 2.50 and your grade is C+\n",&course);
  43. sum+=(ch*2.50);
  44. }else if (marks > 59 && marks < 64){
  45. printf("Your Cgpa of %s is 2.00 and your grade is C\n",&course);
  46. sum+=(ch*2.00);
  47. }else if (marks > 56 && marks < 60){
  48. printf("Your Cgpa of %s is 1.67 and your grade is C-\n",&course);
  49. sum+=(ch*1.67);
  50. }else if (marks > 53 && marks < 57){
  51. printf("Your Cgpa of %s is 1.33 and your grade is D+\n",&course);
  52. sum+=(ch*1.33);
  53. }else if (marks > 49 && marks < 54){
  54. printf("Your Cgpa of %s is 1.00 and your grade is D\n",&course);
  55. sum+=(ch*1.00);
  56. }else if (marks < 50){
  57. printf("Your Cgpa of %s is 0.00 and your grade is F\n",&course);
  58. sum+=(ch*0.0);
  59. }
  60.  
  61.  
  62. }
  63. gpa=sum/total_ch;
  64. printf("Your total GPA of this semester is %f",gpa);
  65.  
  66.  
  67. }