# CGPA & SGPA Calculation Calculator in C

CGPA & SGPA Calculation Calculator are two most popular result publication system in all over the world.

Most of the universities in the world follow this type of result publishing system. CGPA and SGPA stands for:Cumulative Grade point average & Semester grade point average.

As it is a New system to  most of us that’s why many of us don’t know how to calculate CGPA(Cumulative grade  point Average) and how to calculate SGPA(Semester gread point average.)

Form this concern I write  this tutorial on how do you calculate cgpa  or how do you calculate a cumulative grade point average. For this I have written a program in c that will  help you  to find

your correct CGPA & SGPA. Ok Let’s go to see how it is work.

## To Calculate your CGPA(Cumulative grade point average) you have follow following Step:

1. First copy and past of the following program code on Code Blocks or other Compiler that can run C program.

2.Then save as CGPA.cpp

3.Then Compile it.

4. Finally run it & follow it’s command.

## Here is Program code:

```#include <stdio.h>
#include <windows.h>

{
switch((int)m/5)
{
case 20:
case 19:
case 18:
case 17:
case 16: {printf("A+\n"); return(4.00); }
case 15: {printf("A\n"); return(3.75); }
case 14: {printf("A-\n"); return(3.50); }
case 13: {printf("B+\n"); return(3.25); }
case 12: {printf("B\n"); return(3.00); }
case 11: {printf("B-\n"); return(2.75); }
case 10: {printf("C+\n"); return(2.50); }
case 9: {printf("C\n"); return(2.25); }
case 8: {printf("C-\n"); return(2.00); }
default: {printf("F\n"); return(0.00); }
}
}

int main()
{
int n,ct,i,j,at,minimum,sub,marks;
float sum,credit,sum_of_credit=0,sem,sum_of_marks=0,pastcgpa,pcgpa,fcgpa;

printf("\n -------:CGPA CALCULATION:-------");
printf("\nWhat semester CGPA do you Want to calculate:");
scanf("%f",&sem);

printf("Enter the number of theory subjects of Present Semester: ");
scanf("%d",&sub);

for(i=1; i<=sub; i++)
{
printf("Enter subject %d credits and their corresponding marks: (separated by space)\n",i);
scanf("%f %d",&credit,&marks);
sum_of_credit+=credit;
printf("Enter 4 ct marks Of that Subject: ");
minimum=21; sum=0;
for(j=1; j<=4; j++)
{
printf("\nCT[%d]=",j);
scanf("%d",&ct);
minimum=min(minimum,ct);
sum+=ct;
}

marks+=(sum-minimum)/3.0;
printf("\nEnter the attendence mark: ");
scanf("%d",&at);
marks+=at;

}

printf("Enter the number of lab subjects: ");
scanf("%d",&sub);
printf("Enter %d lab/project subjects credit and their corresponding marks: (separated by space)\n",sub);
for(i=1; i<=sub; i++)
{
scanf("%f %d",&credit,&marks);
sum_of_credit+=credit;
}

if(sem>1)
{
printf("Enter the previus semester CGPA:");
scanf("%f",&pastcgpa);
pcgpa=sum_of_marks/sum_of_credit;
fcgpa=(pcgpa+pastcgpa)/sem;

printf("\npresent CGPA= %.2f",pcgpa);
printf("\nFinal CGPA= %.2f",fcgpa);
}
else
printf("\nFirst Semester SGPA= %.2f",sum_of_marks/sum_of_credit);

return 0;
}```

## The output of the above code: ## Related Post or you may Like:

8. ### Java Simple calculator

Updated: October 16, 2014 — 12:03 am