#include<stdio.h>
#include<conio.h>
float c,h,totcre=0,totbot=0;
char gp;
float res=0;
int sub,n,i,a=1;
void grade(float);
void main()
{
clrscr();
printf("\n\n\n\t\t\t\t{{{ 3 BRACES }}}\n");
printf("\n\n\n\t\t ANNA UNIVERSITY CGPA\\GPA CALCULATOR\n");
printf("\t\t\t\t 1.CGPA\n");
printf("\t\t\t\t 2.GPA");
printf("\n (NOTE:IT WILL WORKS FOR PEOPLE WITHOUT BACKLOGS)");
printf("\nENTER YOUR WISH");
scanf("%d",&n);
switch(n)
{
case 1:
printf("\nEnter Number of Subjects Upto Current Semester:");
scanf("%d",&sub);
printf("\nEnter your CREDITS REGISTERED and GRADE EARNED for each subject:");
grade(sub);
break;
case 2:
printf("\nEnter Number of Subjects Upto Current Semester:");
scanf("%d",&sub);
printf("\nEnter your CREDITS REGISTERED and GRADE EARNED for each subject:");
grade(sub);
break;
}
getche();
}
void grade(float sub)
{
for(i=0;i<=sub+sub-1;i++)
{
if(i!=0&&i%2!=0)
{
if(i==1)
{
printf("Sub %d :",a++);
}
else
{
printf("sub %d :",a++);
}
}
scanf("%c",&gp);
switch(gp)
{
case 'a':
h=9;
scanf("%f",&c);
totbot=totbot+((c)*(h));
totcre=totcre+c;
c=0;gp=0;
break;
case 'b':
h=8;
scanf("%f",&c);
totbot=totbot+((c)*(h));
totcre=totcre+c;
c=0;gp=0;
break;
case 'c':
h=7;
scanf("%f",&c);
totbot=totbot+((c)*(h));
totcre=totcre+c;
c=0;gp=0;
break;
case 'd':
h=6;
scanf("%f",&c);
totbot=totbot+((c)*(h));
totcre=totcre+c;
c=0;gp=0;
break;
case 'e':
h=5;
scanf("%f",&c);
totbot=totbot+((c)*(h));
totcre=totcre+c;
c=0;gp=0;
break;
case 's':
h=10;
scanf("%f",&c);
totbot=totbot+((c)*(h));
totcre=totcre+c;
c=0;gp=0;
break;
}
}
res=(float) (totbot/totcre);
printf("YOUR CGPA =%.3f",res);
printf("\nALL THE BEST---CONGRATS");
}