Programming
total calculation of cgpa

### Question Description

use c++ program to calculate the total cgpa of a student doing 40 courses

#include<iostream.h> // for inpit and output
#include<string.h> // for string nama...
using namespace std; // for name space..

struct student // declare struct
{
string name,no_matric;
float credit_hour[10];
}student1;

main()
{
int credit_hours[10];
int sem,total_subject; //'b', 'a',total_credit_hours and total_point
//are removed
float value[10],gpa[10],get_point[10];
float cgpa;
float total_point_sem = 0; //Initialise value
int total_credit_hours_sem = 0; //Initialise value
cin.ignore();

cout << "\t\ ================ ";
cout << "\n\t\ STUDENT'S REKOD " << endl;
cout << "\t\ ================ " << endl;

cout << "\n ENTER STUDENT'S NAME : "; //Enter student's name
getline(cin,student1.name);
cout << " ENTER STUDENT'S MATRIC NUMBER : "; //Enter student's matric number
getline(cin,student1.no_matric);
cout << " ENTER TOTAL SEM TAKEN :"; //Total semester taken by the student
cin >> sem;

for(int a = 0; a< sem ; a++) //'a' declared as int in for()[newly added]
{
int b; //newly added line,'b' choose to add it here because, if not, error will be occured : 'b' for gpa[b] will become undefined...

int total_credit_hours = 0; //newly added
float total_point = 0; //newly added
cout << "\n ENTER SUBJECT TAKEN FOR SEM : " << a+1 << ":"; //Enter total number of subject taken for each sem
cin >> total_subject;
for(int b = 0; b< total_subject; b++) //loop for the courses
{
cin.ignore();
cout << " ENTER SUBJECT CODE : "; //Enter subject code
getline(cin,student1.sub_code[b]);
cout << " ENTER SUBJECT NAME : "; //Enter subject name
getline(cin,student1.sub_name[b]);
cout << " ENTER SUBJECT'S CREDIT HOUR : "; //Enter credit hours of the subject
cin >> student1.credit_hour[b];
cin.ignore();
cout << " ENTER SUBJECT GRED : "; //Enter grade gained by student for every subject

value[b]=4;
value[b]=3.75;
value[b]=3.5;
value[b]=3;
value[b]=2.75;
value[b]=2.5;
value[b]=2;
value[b]=1.75;
value[b]=1.5;
value[b]=1;
else
value[b]=0;

get_point[b] = student1.credit_hour[b] * value[b]; //multiply of credit hours and grade get for each subject
total_credit_hours +=student1.credit_hour[b]; //total cerdit hours for a sem
total_point += get_point[b]; //total points(multiple of credits hours and grade)get for a sem
}

gpa[b] = total_point / total_credit_hours; //calculate GPA for each sem

total_point_sem += total_point; //Total points(multiple of grade and credit hours) get for all semester

total_credit_hours_sem += total_credit_hours; //credits hour get for all semester
}

cgpa = total_point_sem / total_credit_hours_sem; //calculate CGPA

cout << "\n =================================================== ";
cout <<"\n NAME : " << student1.name << endl; //display name of student
cout <<" NO MATRIC : "<< student1.no_matric << endl;
for(int a = 0; a< sem ; a++) //Declaration of 'a' as int in for()
{
cout <<" SUBJECT CODE \t" << " SUBJECT NAME \t" << " SUBJECT CREDIT HOURS " <<endl;
for(int b=0; b<total_subject; b++) //Declaration of 'b' as int in for()
{
cout << " " << student1.sub_code[b] << " : " << student1.sub_name[b]<< " : " << student1.credit_hour[b] << endl;
}
cout << " GPA" <<a+1<< " : " <<gpa[a] << endl;
}
cout << " CGPA : "<<cgpa<<endl;

cout << "\n =================================================== ";

}

codershelp (16)
Cornell University
Review

Anonymous
I was on a very tight deadline but thanks to Studypool I was able to deliver my assignment on time.

Anonymous
The tutor was pretty knowledgeable, efficient and polite. Great service!

Anonymous
Heard about Studypool for a while and finally tried it. Glad I did caus this was really helpful.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors