#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; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter