Auto AdSense

Monday, 10 June 2013

C++ program to calculate CGPA

//C++ program to calculate CGPA
using namespace std;
#include<iostream>
#include<conio.h>
int main()
{
int i,n,gp[20],c[20],sum,csum;
char g[20];
float cgpa;



cout<<"\n\t\t\t CGPA  Calculation";

cout<<"\n\n Enter number of Courses :";
cin>>n;

for(i=0;i<n;i++)
{
cout<<"\n\n Enter Grade of Course-"<<i+1;
cout<<" :";
cin>>g[i];
if(g[i]=='X'||g[i]=='x')
gp[i]=10;
else if(g[i]=='A'||g[i]=='a')
gp[i]=8;
else if(g[i]=='B'||g[i]=='b')
gp[i]=7;
else if(g[i]=='C'||g[i]=='c')
gp[i]=6;
else if(g[i]=='D'||g[i]=='d')
gp[i]=5;
else if(g[i]=='E'||g[i]=='e')
gp[i]=4;
else
gp[i]=0;

cout<<"\n Enter Credit of Course-"<<i+1;cout<<" :";
cin>>c[i];

}
sum=csum=0;

for(i=0;i<n;i++)
{
sum=sum+c[i]*gp[i];
csum=csum+c[i];
}
cgpa=(float)sum/csum;


cout<<"\n\n\n\n\n\n\t\tCongratulations\n\n\t\t\t\t Your CGPA is "<<cgpa;

getch();

return 0;
}

No comments:

Post a Comment