You are on page 1of 2

#include <stdio.

h>
float gpa();
int main(){
int a,b,c,d;
float aa,bb,cc,dd,e,f,g,h;
printf("Enter the marks of the 1st course: ");
scanf("%d",&a);
aa=gpa(a);
printf("Enter the marks of the 2nd course: ");
scanf("%d",&b);
bb=gpa(b);
printf("Enter the marks of the 3rd course: ");
scanf("%d",&c);
cc=gpa(c);
printf("Enter the marks of the 4th course: ");
scanf("%d",&d);
dd=gpa(d);
e=((aa+bb+cc+dd)/4);
printf("Your GPA of the Current Semester is %f",e);
printf("\n\nEnter your previous CGPA: ");
scanf("%f",&f);
printf("Enter the number of Credits Completed: ");
scanf("%f",&g);
h=(((e*12)+(f*g))/(12+g));
printf("Your New CGPA is %f\n\n",h);
}
float gpa(int x){
float gpa;
if ((x>=94)&&(x<=100)){
printf("GPA 4.00\n");
gpa=4.00;
}
if ((x>=90)&&(x<94)){
printf("GPA 3.75\n");
gpa=3.75;
}
if ((x>=86)&&(x<90)){
printf("GPA 3.50\n");
gpa=3.50;
}
if ((x>=82)&&(x<86)){
printf("GPA 3.25\n");
gpa=3.25;
}
if ((x>=78)&&(x<82)){
printf("GPA 3.00\n");
gpa=3.00;
}
if ((x>=74)&&(x<78)){
printf("GPA 2.75\n");
gpa=2.75;
}
if ((x>=70)&&(x<74)){
printf("GPA 2.50\n");
gpa=2.50;
}
if ((x>=66)&&(x<70)){
printf("GPA 2.25\n");

gpa=2.25;
}
if ((x>=62)&&(x<66)){
printf("GPA 2.00\n");
gpa=2.00;
}
if ((x>=58)&&(x<62)){
printf("GPA 1.75\n");
gpa=1.75;
}
if ((x>=54)&&(x<58)){
printf("GPA 1.50\n");
gpa=1.50;
}
if ((x>=38)&&(x<50)){
printf("GPA 1.00\n");
gpa=1.00;
}
if ((x>=0)&&(x<38)){
printf("GPA 0.00\n");
gpa=0.00;
}
return gpa;
}

You might also like