-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedha2.txt
45 lines (35 loc) · 847 Bytes
/
medha2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
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);
}