Advertisement
Guest User

MM

a guest
Dec 7th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. // Declare variables
  6. int grade[5], g, classnum[9], c;
  7. char name[24], n;
  8. float GPA=0.0, grade_point=0.0, result=0.0;
  9.  
  10. // Input student names implying amount of students
  11. for(n=0; n<25; n++) {
  12. scanf(" %s", &name[n]);
  13. printf("Please enter student names: %s.", name[n]);
  14.  
  15. // Input number of classes
  16. for(c=0; c<10; c++) {
  17. scanf(" %d", &classnum[c]);
  18. printf("Please enter amount of classes (max.10): %d", classnum[c]);
  19.  
  20. // Input grades
  21. for(g=0; g<=classnum; g++) {
  22. scanf(" %d", &grade[g]);
  23. printf("Please enter students' grades: %d.", grade[g]);
  24. }
  25.  
  26. // Conversion of grades
  27. if (grade == "A"){
  28. grade_point = 4.0;
  29. }
  30. if (grade == "B"){
  31. grade_point = 3.0;
  32. }
  33. if (grade == "C")
  34. {
  35. grade_point =2.0;
  36. }
  37. if (grade == "D"){
  38. grade_point = 1.0;
  39. }
  40. if (grade == "F"){
  41. grade_point = 0.0;
  42. }
  43.  
  44. // GPA formula
  45. result += grade_point[g];
  46. GPA = result/classnum[c];
  47. }
  48. }
  49.  
  50. // Print results in a table
  51. printf("\n Student name \t Grades \t GPA");
  52. for(n=0; n<25; n++) {
  53. printf(" %s \t %d \t %f", name[n], grade[g], GPA);
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement