Information and study is a popular blog of programming languages (C,C++,java),Data structure and algorithms,object oriented programming, and interviewing questions for freshers. This blog is essential for software engineers and developers.
Program to Calculate GPA and CGPA in C++
How to find CGPA:
Step 1:
First enter your all subject gpa
Like
80 plus marks 4gpa
79 marks 3.9
78 marks 3.8
Similarly
70 to 77. 3 to 3.7 GPA
60 to 69. 2 to 2.9 GPA
50 to 59 1 to 1.9 GPA
Step 2:
Multiply all subject gpa to it's Credit hour
Step 3:
Calculate total GPA by adding all subject Gpa
After calculating total GPA
So next
Total Gpa divide with Total subject credit hour
Step 4:
Enter previous semester Gpa and add with new Gpa and divide by total credit hour in boat semester.
GPA = (sum of product of credit * grade points for all subjects) / total credits
Write a program to calculate GPA and CGPA in c++?
#include<iostream>
using namespace std;
int main()
{
float ds,eng,discrete,network,hrm;
cout<<"\t\t***___Created By Jhangir Mughal___***"<<endl;
cout<<"\n\nEnter Data Structure Gpa:> ";
cin>>ds;
cout<<"Enter Discrete Structure Gpa:> ";
cin>>discrete;
cout<<"Enter Network Gpa:> ";
cin>>network;
cout<<"Enter HRm Gpa:> ";
cin>>hrm;
cout<<"Enter Critical Reading and Academic Writing Gpa:> ";
cin>>eng;
float gpads,gpaeng,gpadis,gpanet,gpahr;
gpads=ds*4;
gpaeng=eng*3;
gpadis=discrete*3;
gpanet=network*3;
gpahr=hrm*3;
float totalGpa,tcredhr=16;
totalGpa=gpads+gpaeng+gpadis+gpanet+gpahr;
float finalGpA;
finalGpA=totalGpa/tcredhr;
cout<<"\nYour Gpa Is:> "<<finalGpA<<endl;
float Gpa1st,credhr1st;
cout<<"Enter your First Semester Gpa:> ";
cin>>Gpa1st;
cout<<"Enter your 1st Semester Credit Hours:> ";
cin>>credhr1st;
float Gpa2nd, credhr2nd;
cout<<"\nEnter your 2nd Semester Gpa:> ";
cin>>Gpa2nd;
cout<<"Enter your 2nd Semester Credit Hours:> ";
cin>>credhr2nd;
float firstSem,secSem,thirdSem;
firstSem=credhr1st*Gpa1st;
secSem=credhr2nd*Gpa2nd;
thirdSem=tcredhr*finalGpA;
float CGPA_2ndsem,T3rd_CGPA;
CGPA_2ndsem=(firstSem+secSem)/(credhr1st+credhr2nd);
cout<<"Your CGPA in 2nd semester:> "<<CGPA_2ndsem;
T3rd_CGPA=(firstSem+secSem+thirdSem)/(credhr1st+credhr2nd+tcredhr); cout<<"\nYour CGPA in 3rd semester:>>> "<<T3rd_CGPA;
}
Out put :
Another program for GPA calculation:
#include<iostream>
using namespace std;
int main()
{
float dsa,netw,eng,disc,hrm;
int l;
cout<<"-------------If your marks are greater than 80 than your gpa is 4-----------"<<endl;
cout<<"\n Enter DSA Gpa :";
cin>>dsa;
cout<<"\n Enter Networking Gpa :";
cin>>netw;
cout<<"\n Enter English Gpa :";
cin>>eng;
cout<<"\n Enter Discrete Gpa :";
cin>>disc;
cout<<"\n Enter HRM Gpa :";
cin>>hrm;
float gpa1,gpa2,gpa3,gpa4,gpa5,gpa6;
gpa1=dsa*4;
gpa2=netw*4;
gpa3=eng*3;
gpa4=disc*3;
gpa5=hrm*3;
float tgpa,tcred=17;
tgpa=gpa1+gpa2+gpa3+gpa4+gpa5+gpa6;
float finalgpa;
finalgpa=tgpa/tcred;
cout<<"\nYour Gpa Is: "<<finalgpa<<endl;
cout<<"-------------- CGPA Calculating -----------------\n\n"<<endl;
cout<<"How many semester results do you want input? :"<<endl;
cin>>l;
cout<<"\n\n"<<endl;
float semrs[l];
int i;
for(i=0;i<l;i++)
{
cout<<" Enter "<<i+1<<" Semester GPA : ";
cin>>semrs[i];
cout<<"\n"<<endl;
}
float semtot=0;
for(int j=0;j<l;j++)
{
semtot=semtot+semrs[j];
}
cout<<"******** Your CGPA is "<<semtot/l<<" **********"<<endl;
}