View Single Post
  #1 (permalink)  
Old May 21st, 2017, 11:39 AM
avavida avavida is offline
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2017
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default calculating gpa with only grades?

is there some sort of calculation for just GPA without knowing the credits? i wrote a program which shows the average 20students have each after taking 3 exams each. now i must print the GPA of each student, as well as which has the highest GPA. i looked up some formulas via google search and didn't find much because the way GPA is calculated involves the credits taken.
code:
#include<stdio.h>
int main()
{
float exam_a[20] = { 77, 65, 89, 79, 85, 90, 98, 45, 83, 75, 71, 85, 85, 80, 68, 72, 56, 82, 63, 80} ;
float exam_b[20] = { 87, 92, 84, 89, 75, 99, 92, 66, 80, 77, 56, 79, 76, 78, 88, 78, 66, 70, 69, 90} ;
float exam_c[20] = { 45, 77, 87, 77, 88, 83, 94, 71, 73, 83, 52, 80, 93, 88, 76, 64, 75, 80, 85, 52} ;
int k;
char letter;
float student[20];
float sum_a = 0, sum_b = 0, sum_c = 0, sum_d = 0, sum_f = 0;
int tot_a = 0, tot_b = 0, tot_c = 0, tot_d = 0, tot_f = 0;
for (k = 0; k < 20; ++k){
sum_a = sum_a + exam_a[k];
student[k] = exam_a[k] + exam_b[k] + exam_c[k];
student[k] = (student[k])/3;


if (student[k] >= 90){
letter = 'A';
++tot_a;
}
else if (student[k] >= 80){
letter = 'B';
++tot_b;
}
else if (student[k] >= 70) {
letter = 'C';
++tot_c;
}
else if (student[k] >= 60) {
letter = 'D';
++tot_d;
}

else {
letter = 'F';
++tot_f;
}
}
printf("(Based on Averages)Number of As = %i \number of Bs = %i \number of Cs = %i \number of Ds = %i \number of Fs = %i \n", tot_a, tot_b, tot_c, tot_d, tot_f);

}
is to show which students got what grades on the average of 3 exams. i was thinking of maybe just doing if 95 and over store 4.0 90 and over store 3.7 and so on.. unless theres a better way to calculate this.
Example: https://gpahub.net
Reply With Quote