Calculate the CGPA in c#

Calculate the CGPA in c#

In this article, how will you calculate CGPA to CGPA %

Full form of CGPA - Cumulative Grade Point Average

 

using System;
 
class Usingcsharp{
 
public static double CgpaCalc(double[] marks, int n)
{
    double []grade = new double[n];
 
    double cgpa, sum = 0;
 
    for(int i = 0; i < n; i++)
    {
        grade[i] = (marks[i] / 10);
    }
 
    for(int i = 0; i < n; i++)
    {
        sum += grade[i];
    }
 
    cgpa = sum / n;
 
    return cgpa;
}
 
public static void Main(String []args)
{
    int n = 6;
    double[] totalmarks = { 89, 81, 78, 80, 99, 94 };
    double cgpa = CgpaCalc(totalmarks, n);
 
    Console.WriteLine("CGPA = " + cgpa);
    Console.WriteLine("CGPA Percentage = {0:F2}",  cgpa * 9.5);
}
}

2021-10-03