GPA and CGPA Calculator using C++ | How to Program
OUTPUT
GPA and CGPA Calculator using C++ | How to Program
#include <iostream>
#include<conio.h>
float gpa(float );
using namespace std;
float gpa(float nmbr)
{
cout << "\ntotal Number of subjects: ";
cin >> nmbr;
float l,tg,i,n,gp,g;
int c;
for( c = 0; c < nmbr; c++)
{
cout << "\nMarks of sbj no. " << c+1 << " = ";
cin >>n;
cout<<"\ncradit hours of that sbj. "<<c+1<<" = ";
cin>>l;
if(n<=49.9)
i=0;
if(n<=54.9&&n>=50.0)
i=1.4;
if(n<=59.9&&n>=55.0)
i=1.7;
if(n<=64.9&&n>=60.0)
i=2;
if(n<=69.9&&n>=65.0)
i=2.3;
if(n<=74.9&&n>=70.0)
i=2.7;
if(n<=79.9&&n>=75.0)
i=3;
if(n<=84.9&&n>=80.0)
i=3.3;
if(n<=89.9&&n>=85.0)
i=3.7;
if(n>=90.0&&n<=100.0)
i=4.0;
if(l==4)
i=i*4;
if(l==3)
i=i*3;
tg=tg+l;
gp=gp+i;
}
g=gp/tg;
return g;
}
int main()
{
float s,s1=0,m,n,ts;
cout<<"\nenter the number of smesters:";
cin>>ts;
for(int i=0;i<ts;i++)
{
cout<<"\nfor smester:"<<i+1;
s=gpa(n);
cout<<"\nGPA of smester : "<<i+1<<" = "<<s<<endl;
s1=s1+s;
}
cout<<" CGPA = "<<s1/ts;
getch();
}
COMMENTS