I hope I am postin gin the right spot.I am new to this site.
I need help with sorting the grades, please. Can anyone help?Thanks

include<iostream>
#include<iomanip>
using namespace std;



int main()
{
	double *grades;           //point used to point to an array that holds grad
	double total = 0.0;            // total of grades
	double average;              // holds the average grades
	int count;                 // loop counter
	int numGrades;			   //grades that will be processed

	//get the number of months
	cout <<"How many grades will be processed?" << endl;
	cin >>numGrades;

	//allocate memory for the number of grades
	grades= new double[numGrades];

	//Get the grades
	cout <<"enter the grades below."<< endl;
	for(count=0; count < numGrades; count++  )

	 {
	 cout << "Grade " << (count + 1) << ":";
	 cin >> grades[count];
	 }

	 //calculate the grades
	 for(count=0;count <numGrades;count++)
	 {
		 total += grades[count];
	 }
	 //calculate the average grades
	 average += total/numGrades;

	 //Display the results
	 cout << fixed <<showpoint << setprecision(1);
	 cout <<"\n\nTotal  Grades: " << total << endl;
	 cout <<"Average Grade: " << average << endl;

	 //Free dynamically allocated memory
	 delete [] grades;
	 grades= 0;

	 system("Pause");

	return 0;
}

you could use standard C function qsort(), c++ std::sort(), or write your own sort algorithm.

Thanks I really appreciate the help.

something is wrong with my bubble sort. Help from anyone. Thanks

//---------------------------------------------------------------------------

#include<iostream>
#include<iomanip>

using namespace std;

//function prototypes
 void bubbleSortArray(int [], int);
void displayArray(int[], int);

int main()
{
    int *grades;           //point used to point to an array that holds grad
    double total = 0.0;            // total of grades
    double average;              // holds the average grades
    int count;                 // loop counter
    int numGrades;             //grades that will be processed



    //get the number of months
    cout <<"How many grades will be processed?" << endl;
    cin >>numGrades;

    //allocate memory for the number of grades
    grades= new int[numGrades];

    //Get the grades
    cout <<"enter the grades below."<< endl;
    for(count=0; count < numGrades; count++  )

     {
     cout << "Grade " << (count + 1) << ":";
     cin >> grades[count];

     }
      cout <<"The values before the bubble sort array are:"<<endl;
      displayArray(grades,numGrades);


    {
      //sort the grades
      bubbleSortArray(grades,numGrades);

      //Display the sorted values
      cout <<"The sorted grades are:\n.";
      displayArray(grades,numGrades);



      }
     //calculate the grades
     for(count=0;count <numGrades;count++)
     {
         total += grades[count];

     //calculate the average grades
     average += total/numGrades;

     //Display the results
     cout << fixed <<showpoint << setprecision(1);
     cout <<"\n\nTotal  Grades: " << total << endl;
     cout <<"Average Grade: " << average << endl;

     //Free dynamically allocated memory
     delete [] grades;
     grades= 0;

     system("Pause");

    return 0;
}
     }

  //******************************************************************
// bubbleSortArray
//
// task: to sort values of an array in ascending order
// data in: the array, the array size
// data out: the sorted array
//
//******************************************************************
   void bubbleSortArray(int array[], int elems)
{
bool swap;
int grades;
int bottom = grades - 1; // bottom indicates the end part of the
// array where the largest values have
// settled in order
do
{
swap = false;
for (int count = 0; count < bottom; count++)
{
if (array[count] <= array[count+1])
{ // the next three lines do a swap
grades = array[count];
array[count] = array[count+1];
array[count+1] = grades;
swap = true; // indicates that a swap occurred
}
}
 bottom--; // bottom is decremented by 1 since each pass through
// the array adds one more value that is set in order
} while(swap != false);
// loop repeats until a pass through the array with
// no swaps occurs
}
//******************************************************************
// displayArray
//
// task: to print the array
// data in: the array to be printed, the array size
// data out: none
//
//******************************************************************
void displayArray(int array[], int numGrades) // function heading
{ // displays the array
for (int count = 0; count < numGrades; count++)
cout << array[count] << " " << endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.