-
Notifications
You must be signed in to change notification settings - Fork 0
/
GPA.c
67 lines (66 loc) · 1.5 KB
/
GPA.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<stdio.h>
#include<string.h>
int main()
{
float points,total=0.0,GPA,credithour=0.0,totalhour=0.0;
char grade[10];
int subjects;
printf("Enter Number of sujects :");
scanf("%d",&subjects) ;
for(int i= 1;i<=subjects;i++)
{
printf("Enter your grade in subject (%d) : \n",i );
scanf("%s",grade);
printf("Enter your Credit hour of subject (%d) : \n",i);
scanf("%f",&credithour);
totalhour=totalhour+credithour;
if ( strcmp(grade,"A") == 0 )
{
points=4.0;
}
else if (strcmp(grade,"A-")==0)
{
points=3.67;
}
else if (strcmp(grade,"B+")==0)
{
points=3.33;
}
else if (strcmp(grade,"B")==0)
{
points=3.0;
}
else if(strcmp(grade,"B-")==0)
{
points=2.67;
}
else if (strcmp(grade,"C+")==0)
{
points=2.33;
}
else if (strcmp (grade,"C")==0)
{
points=2.0;
}
else if (strcmp (grade,"C-")==0)
{
points=1.67;
}
else if (strcmp(grade,"D+")==0)
{
points=1.33;
}
else if (strcmp(grade,"D+")==0)
{
points=1.00;
}
else if (strcmp(grade,"F")==0)
{
points=0;
}
total=total+points*credithour;
}
GPA=total/totalhour;
printf("Your GPA is %.2f ",GPA);
return 0;
}