How to call the selection sort function in main
<p>So the question is to Add selection sort function to grade program above. Program should display list of grades in sorted ascending order, we are giving the selection sort function and cant change it, my question is how would I call it from the main function</p>

<p>Here is my code`</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

double average(double x[], int n);
double maximum(double x[], int n);
double minimum(double x[], int n);
int nAboveAvg(double x[], int n);
void sort(double x[], int npts);


int main()
{
   double grades[50];
   int ngrades;

   cout&lt;&lt;"How many grades? (max = 50) ";
   cin&gt;&gt;ngrades;

   //create for loop to get grades from user
   for(int i = 0; i&lt;ngrades; i++)
   {
      cout&lt;&lt;"Enter grade ";
      cin&gt;&gt; grades[i];
      while(grades[i]&lt; 0 || grades[i] &gt; 100)
      {
          cout&lt;&lt;"Invalid grade- please enter again"&lt;&lt;endl;
          cin&gt;&gt;grades[i];
      }
   }

   //call the functions
   double avg = average(grades, ngrades);
   double max = maximum(grades, ngrades);
   double min = minimum(grades, ngrades);
   int nAbove = nAboveAvg(grades, ngrades);

       //Calling the sort function
   sor = sort(grades, ngrades);
   //display results



   cout &lt;&lt; "Average = " &lt;&lt; avg &lt;&lt; endl;
   cout &lt;&lt; "# above average = " &lt;&lt; nAbove &lt;&lt; endl;
   cout&lt;&lt;"Max value is = "&lt;&lt;max&lt;&lt;endl;
   cout&lt;&lt;"Min value is = "&lt;&lt;min&lt;&lt;endl;
   cout&lt;&lt;"Array sorted "&lt;&lt;sor&lt;&lt;endl;

}

void sort(double x[], int npts)
{
  double min_value;
  int min_index;
  double temp;
  for(int i= 0; i&lt;npts - 1; i++)
  {
      for(int j = i + 1; j&lt;npts; j++)
      {
          if(x[j] &lt; min_value)
          {
              min_value = x[i];
              min_index = j;
          }
      }

      temp = x[min_index];
      x[min_index] = x[i];
      x[i] = temp;
  }
  return;
}
</code></pre>

<p>` </p>