└── cgpa /cgpa: -------------------------------------------------------------------------------- 1 | // C++ program to calculate the CGPA 2 | // and CGPA percentage of a student 3 | #include 4 | using namespace std; 5 | 6 | double CgpaCalc(double marks[], int n) 7 | { 8 | // Variable to store the grades in 9 | // every subject 10 | double grade[n]; 11 | 12 | // Variables to store CGPA and the 13 | // sum of all the grades 14 | double cgpa, sum = 0; 15 | 16 | // Computing the grades 17 | for(int i = 0; i < n; i++) 18 | { 19 | grade[i] = (marks[i] / 10); 20 | } 21 | 22 | // Computing the sum of grades 23 | for(int i = 0; i < n; i++) 24 | { 25 | sum += grade[i]; 26 | } 27 | 28 | // Computing the CGPA 29 | cgpa = sum / n; 30 | 31 | return cgpa; 32 | } 33 | 34 | // Driver code 35 | int main() 36 | { 37 | int n = 5; 38 | double marks[] = { 90, 80, 70, 80, 90 }; 39 | 40 | double cgpa = CgpaCalc(marks, n); 41 | 42 | cout << "CGPA = "; 43 | printf("%.1f\n", cgpa); 44 | cout << "CGPA Percentage = "; 45 | printf("%.2f", cgpa * 9.5); 46 | } 47 | 48 | 49 | --------------------------------------------------------------------------------