0% found this document useful (0 votes)
15 views4 pages

Name: Roll No:: Muhammad Ehtisam Baig

The document describes a C++ program that creates a grade sheet for four students in three subjects, calculates their GPA for each subject and overall CGPA, and displays the results. It includes the source code that takes student roll numbers and marks as input, calculates GPA and CGPA using formulas, stores the results in a 2D array, displays the grade sheet, and finds the student with the highest CGPA. The output displayed is the grade sheet table with the roll number of the student attaining the highest CGPA of 2.6.

Uploaded by

EHTISAM BAIG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Name: Roll No:: Muhammad Ehtisam Baig

The document describes a C++ program that creates a grade sheet for four students in three subjects, calculates their GPA for each subject and overall CGPA, and displays the results. It includes the source code that takes student roll numbers and marks as input, calculates GPA and CGPA using formulas, stores the results in a 2D array, displays the grade sheet, and finds the student with the highest CGPA. The output displayed is the grade sheet table with the roll number of the student attaining the highest CGPA of 2.6.

Uploaded by

EHTISAM BAIG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1

Name:
Muhammad Ehtisam Baig
Roll no:
RP22-EE-433

Problem Based Learning


Problem Statement: Write a C++ program to create a grade sheet for four
students appearing in three subjects. Calculate GPA of each student for each
subject and CGPA. Display the results sheet and the roll number and score of the
student attaining highest CGPA.

Roll Score Score Score GPA GPA GPA CGPA


Number Subject Subject Subject Subject Subject Subject
1 2 3 1 2 3

401 75 84 50 3.3 3.7 1.0 2.6


--- --- --- --- --- --- --- ---
--- --- --- --- --- --- --- ---

Roll No. 401 secured highest CGPA of 2.6 among the class.

Source code
#include<iostream>
using namespace std;
float cgpa(float a , float b , float c)
{
float v;
v=(((a*4)+(b*4)+(c*4))/12);
return v;
}
float gpa(int a)
{
float h;
if (a>=85)
{
2

h=4;
}
if (a>=80 && a<85)
{
h=3.7;
}
if (a>=75 && a<80)
{
h=3.3;
}
if (a>=70 && a<75)
{
h=3;
}
if (a>=65 && a<70)
{
h=2.7;
}
if (a>=60 && a<65)
{
h=2.3;
}
if (a>=55 && a<60)
{
h=2;
}
if (a>=50 && a<55)
{
h=1.7;
}
if (a<50)
{
h=1;
}
return h;
}
int main()
{
int r = 4;
int c = 8;
float o=1;
float p=1;
float q=1;
float a[r][c];
for (int i=0 ; i<r ; i++)
3

{
for (int j=0 ; j<c ; j++)
{
if (j==0)
{
cout<<"Enter roll number of student "<<q<<": ";
cin>>a[i][j];
}
else if (j==1 || j==2 || j==3)
{
cout<<"Enter marks of subject "<<o<<": ";
cin>>a[i][j];
o++;
}
else if (j==4 || j==5 || j==6)
{
a[i][j] = gpa(a[i][j-3]);
p++;
}
else if (j==7)
{
a[i][j]=cgpa(a[i][j-3],a[i][j-2],a[i][j-1]);
}
}
q++;
o=1;
}
for (int k=0 ; k<r ; k++)
{
for (int l=0 ; l<c ; l++)
{
cout<<a[k][l];
cout<<" ";
}
cout<<"\n";
}
float max = 0;
int n;
for (int k=0 ; k<r ; k++)
{
for (int l=0 ; l<c ; l++)
{
if (l==7)
{
if (a[k][l]>max)
4

{
max=a[k][l];
n=k;
}
}
}
}
cout<<"Roll no. "<<a[n][0]<<" secured highest CGPA of "<<max<<" among the
class.";
return 0;
}

Output

You might also like