#include<iostream.h>
#include<conio.h>
float gpa(int,int);
float gpa(int om,int tm)
{
float per ,g;
per=float(om)/tm*100;
g=(per>=80?4.00:per>=70?3.5:per>=60?3.0:per>=55?2.5:per>=50?2.0:0.0);
return g;
}
void main()
{
clrscr();
int nc,i,om,tm,ch,tch=0; float g,tg=0;
cout<<"Enter number of cources="; cin>>nc;
for(i=1;i<=nc;i++)
{
cout<<endl<<"Enter obtained marks="; cin>>om;
cout<<endl<<"Enter total marks="; cin>>tm;
cout<<endl<<"Enter credit hours="; cin>>ch;
g=gpa(om,tm);
tg+=g*ch;
tch+=ch;
}
cout<<endl<<"GPA="<<tg/tch;
getch();
}
No comments:
Post a Comment