In: Computer Science
C++ CODE:
#include <iostream>
using namespace std;
//Grade sequencing function
void getGrades(int grades[], int count) {
    for(int i = 0; i < count; i++){
        cout << "Enter grade " << (i + 1) << ": ";
        cin >> grades[i];
    }
    //Sort grades in increasing sequence
    for(int i = 0; i < count - 1; i++){
        for(int j = 0; j < count - i - 1; j++){
            if(grades[j] > grades[j + 1]){
                //Swap grades
                int temp = grades[j];
                grades[j] = grades[j + 1];
                grades[j + 1] = temp;
            }
        }
    }
}
//Function to return average grade
double getAverage(int grades[], int count){
    double avg = 0.0;
    for(int i = 0; i < count; i++)
        avg += grades[i];
    avg /= count;
    return avg;
}
int main(){
    const int MAX = 30;
    int grades[MAX];
    int count;
    cout << "Enter number of grades: ";
    cin >> count;
    getGrades(grades, count);
    cout << "Sorted grades:\n";
    for(int i = 0; i < count; i++)
        cout << (i + 1) << ". " << grades[i] << endl;
    cout << "Average grade: " << getAverage(grades, count) << endl;
    return 0;
}
SAMPLE OUTPUT:
