Given an array **arr[]** of size **N** which contains the marks of a student in **N subjects**, the task is to calculate the CGPA and the CGPA percentage of the student. **Note:** Consider all marks to be out of 100, for each subject.

CGPA(Cumulative Grade Point Average)is the systematic arrangement in the educational stream to get an average of grade points.

**Examples:**

Input:arr[] = {90, 80, 70, 80, 90}Output:CGPA = 8.2, Percentage = 77.89Explanation:

The grade in each subject respectively out of 10 is {9, 8, 7, 8, 9}.

The CGPA is the average of all the grades = (9 + 8 + 7 + 8 + 9) / 5 = 8.2

The percentage of this CGPA is 77.89.

Input:arr[] = {90, 90, 90, 80, 85}Output:CGPA = 8.7, Percentage = 82.65

**Approach:** In this article, the CGPA is calculated on a scale of 10.

- Input the array from the user containing the marks of the student in N subjects.
- Since the scale is on 10, divide marks in every subject by 10 to find the GPA of the student in each subject.
- The average of all the GPA’s yield the overall CGPA of the student.
- After finding the CGPA, the CGPA percentage can be calculated by the formula:

CGPA% = CGPA * 9.5

- This is a general formula for a scale of 10. However, if the entire calculation is made on a scale of 4, this 9.5 is thereby multiplied by
**2.5**and the CGPA percentage is found by multiplying with**23.75**.

Below is the implementation of the above approach:

## C++

`// C++ program to calculate the CGPA` `// and CGPA percentage of a student` `#include<bits/stdc++.h>` `using` `namespace` `std;` `double` `CgpaCalc(` `double` `marks[], ` `int` `n)` `{` ` ` `// Variable to store the grades in` ` ` `// every subject` ` ` `double` `grade[n];` ` ` `// Variables to store CGPA and the` ` ` `// sum of all the grades` ` ` `double` `cgpa, sum = 0;` ` ` `// Computing the grades` ` ` `for` `(` `int` `i = 0; i < n; i++) ` ` ` `{` ` ` `grade[i] = (marks[i] / 10);` ` ` `}` ` ` `// Computing the sum of grades` ` ` `for` `(` `int` `i = 0; i < n; i++) ` ` ` `{` ` ` `sum += grade[i];` ` ` `}` ` ` `// Computing the CGPA` ` ` `cgpa = sum / n;` ` ` `return` `cgpa;` `}` `// Driver code` `int` `main()` `{` ` ` `int` `n = 5;` ` ` `double` `marks[] = { 90, 80, 70, 80, 90 };` ` ` `double` `cgpa = CgpaCalc(marks, n);` ` ` ` ` `cout << ` `"CGPA = "` `;` ` ` `printf` `(` `"%.1f\n"` `, cgpa);` ` ` `cout << ` `"CGPA Percentage = "` `;` ` ` `printf` `(` `"%.2f"` `, cgpa * 9.5);` `}` `// This code is contributed by Bhupendra_Singh` |

*chevron_right*

*filter_none*

## Java

`// Java program to calculate the CGPA` `// and CGPA percentage of a student` `import` `java.util.Scanner;` `class` `CGPA {` ` ` `public` `static` `double` `CgpaCalc(` `double` `[] marks, ` `int` `n)` ` ` `{` ` ` `// Variable to store the grades in` ` ` `// every subject` ` ` `double` `grade[] = ` `new` `double` `[n];` ` ` `// Variables to store CGPA and the` ` ` `// sum of all the grades` ` ` `double` `cgpa, sum = ` `0` `;` ` ` `// Computing the grades` ` ` `for` `(` `int` `i = ` `0` `; i < n; i++) {` ` ` `grade[i] = (marks[i] / ` `10` `);` ` ` `}` ` ` `// Computing the sum of grades` ` ` `for` `(` `int` `i = ` `0` `; i < n; i++) {` ` ` `sum += grade[i];` ` ` `}` ` ` `// Computing the CGPA` ` ` `cgpa = sum / n;` ` ` `return` `cgpa;` ` ` `}` ` ` `// Driver code` ` ` `public` `static` `void` `main(String args[])` ` ` `{` ` ` `int` `n = ` `5` `;` ` ` `double` `[] marks` ` ` `= { ` `90` `, ` `80` `, ` `70` `, ` `80` `, ` `90` `};` ` ` `double` `cgpa = CgpaCalc(marks, n);` ` ` `System.out.println(` ` ` `"CGPA = "` `+ cgpa);` ` ` `System.out.println(` ` ` `"CGPA Percentage = "` ` ` `+ String.format(` `"%.2f"` `, cgpa * ` `9.5` `));` ` ` `}` `}` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to calculate the CGPA ` `# and CGPA percentage of a student ` `def` `CgpaCalc(marks, n): ` ` ` `# Variable to store the grades in ` ` ` `# every subject ` ` ` `grade ` `=` `[` `0` `] ` `*` `n` ` ` ` ` `# Variables to store CGPA and the ` ` ` `# sum of all the grades ` ` ` `Sum` `=` `0` ` ` ` ` `# Computing the grades ` ` ` `for` `i ` `in` `range` `(n):` ` ` `grade[i] ` `=` `(marks[i] ` `/` `10` `)` ` ` ` ` `# Computing the sum of grades ` ` ` `for` `i ` `in` `range` `(n):` ` ` `Sum` `+` `=` `grade[i]` ` ` ` ` `# Computing the CGPA ` ` ` `cgpa ` `=` `Sum` `/` `n ` ` ` ` ` `return` `cgpa` ` ` `# Driver code` `n ` `=` `5` `marks ` `=` `[ ` `90` `, ` `80` `, ` `70` `, ` `80` `, ` `90` `]` `cgpa ` `=` `CgpaCalc(marks, n)` ` ` `print` `(` `"CGPA = "` `, ` `'%.1f'` `%` `cgpa)` `print` `(` `"CGPA Percentage = "` `, ` `'%.2f'` `%` `(cgpa ` `*` `9.5` `))` `# This code is contributed by divyeshrabadiya07` |

*chevron_right*

*filter_none*

## C#

`// C# program to calculate the CGPA` `// and CGPA percentage of a student` `using` `System;` `class` `GFG{` `public` `static` `double` `CgpaCalc(` `double` `[] marks,` ` ` `int` `n)` `{` ` ` ` ` `// Variable to store the grades in` ` ` `// every subject` ` ` `double` `[]grade = ` `new` `double` `[n];` ` ` `// Variables to store CGPA and the` ` ` `// sum of all the grades` ` ` `double` `cgpa, sum = 0;` ` ` `// Computing the grades` ` ` `for` `(` `int` `i = 0; i < n; i++)` ` ` `{` ` ` `grade[i] = (marks[i] / 10);` ` ` `}` ` ` `// Computing the sum of grades` ` ` `for` `(` `int` `i = 0; i < n; i++)` ` ` `{` ` ` `sum += grade[i];` ` ` `}` ` ` `// Computing the CGPA` ` ` `cgpa = sum / n;` ` ` `return` `cgpa;` `}` `// Driver code` `public` `static` `void` `Main(String []args)` `{` ` ` `int` `n = 5;` ` ` `double` `[] marks = { 90, 80, 70, 80, 90 };` ` ` `double` `cgpa = CgpaCalc(marks, n);` ` ` `Console.WriteLine(` `"CGPA = "` `+ cgpa);` ` ` `Console.WriteLine(` `"CGPA Percentage = {0:F2}"` `,` ` ` `cgpa * 9.5);` `}` `}` `// This code is contributed by Amit Katiyar` |

*chevron_right*

*filter_none*

**Output:**

CGPA = 8.2 CGPA Percentage = 77.90

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Find the total marks obtained according to given marking scheme
- Program to calculate Percentile of a student based on rank
- Maximum students to pass after giving bonus to everybody and not exceeding 100 marks
- Student Information Management System
- Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given
- Find the number obtained after concatenation of binary representation of M and N
- Construct a frequency array of digits of the values obtained from x^1, x^2, ........, x^n
- Number of distinct integers obtained by lcm(X, N)/X
- Maximum array sum that can be obtained after exactly k changes
- Total distinct pairs from two arrays such that second number can be obtained by inverting bits of first
- Minimum sum obtained from groups of four elements from the given array
- Count of integers obtained by replacing ? in the given string that give remainder 5 when divided by 13
- Minimum integer that can be obtained by swapping adjacent digits of different parity
- Check if N can be obtained from 1 by repetitively multiplying by 10 or 20
- Check if N can be obtained by repetitive addition or subtraction of two given numbers
- Check if sum Y can be obtained from the Array by the given operations
- Check if K can be obtained by performing arithmetic operations on any permutation of an Array
- Smallest array that can be obtained by replacing adjacent pairs with their products
- Cost required to empty a given array by repeated removal of maximum obtained by given operations
- Find a number K having sum of numbers obtained by repeated removal of last digit of K is N

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.