Average grade using array

PHOTO EMBED

Fri Dec 10 2021 15:36:10 GMT+0000 (Coordinated Universal Time)

Saved by @abzal_nurgazy #c++

#include <iostream>
using namespace std;
const int MAX_ARRAY = 60;

int main()
{
    int numberofStudents, currGrade,sum;
    double average;
    int grades[MAX_ARRAY];

    cout << "Enter the number of students" << endl;
    cin >> numberofStudents;
    cout << "Enter the grades separated by a space" << endl;
    
    // Reading the grades one by one and uploading it inside the array
    for (int i = 0; i < numberofStudents; i++) {
        cin >> currGrade;
        grades[i] = currGrade;
    }
    // calculating the sum and average

    sum = 0;
    for (int i = 0; i < numberofStudents; i++) {
        sum += grades[i];
    }
    average = (double)sum / (double)numberofStudents;

    cout << "the average grade is " << average << endl;
    for (int i = 0; i < numberofStudents; i++) {
        if (grades[i] > average) {
            cout << "The grades that is more than the average is " << grades[i] << endl;
        }
    }
    
    return 0;
}
content_copyCOPY