// This program Enter test scores and sort them in oder and Averages them
#include
#include
using namespace std;
int main()
{
double *score, total = 0, average;
int TestScores, count;
cout << "How many Test Scroes do you wish to enter ";
cin >> TestScores;
score = new double[TestScores]; // Allocate memory
// Get the Test Scores
cout << "Enter each students test scores.\n";
for (count = 0; count < TestScores; count++)
{
cout << "Student " << (count + 1) << ": ";
cin >> score[count];
}
//bubble sort
for (int i=0; i
for (int j=i; j
if (score[i] < score[j])
{
double tmpscore = score[i];
score[i] = score[j];
score[j] = tmpscore;
}
// Calculate the total Scores
for (count = 0; count < TestScores; count++)
{
total += score[count];
}
// Calculate the average Test Scores
average = total / TestScores;
// Display the results
cout << fixed << showpoint << setprecision(2);
cout << "Average Score: " << average << endl;
// Free dynamically allocated memory
delete [] score;
return 0;
}