title: C++ Dynamically Allocate an Array, Bubblesort + Finding Average
body: <p>I have the bubblesort created and I think I have the average one too. Not sure. But I need to implement it into my main function and I'm not sure how to. Kind of stuck right now. Any help would be great. Thanks!</p>
  
  <blockquote>
    <p>Write a program that dynamically allocates an array large enough to
    hold a user-defined number of test scores.</p>
    
    <p>Once all the scores are entered, the array should be passed to a
    function (you create) as a pointer that sorts it in ascending order. 
    This function can be named sortArray and will take two parameters:
    (double* anArray, int size).  The function will return true if the
    array is sorted, or false otherwise (for example if size &lt;= 0)</p>
    
    <p>Another function should be created that calculates the average score
    of the items in the array.  This function will take in two parameters
    (double* anyArray, int size) and return the average as a double.</p>
    
    <p>The program should display the sorted array of scores and averages
    with appropriate headings.  </p>
    
    <p>Use pointer notation rather than array notation whenever possible.</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  bool sortArray(double* anArray, int size);
  double averageArray(double* anyArray, int size);
  
  
  int main()
  
  {
      double* anArray;
      double total = 0.0;
      double average;
      int scores;
      int count;
  
      cout &lt;&lt; "How many test scores are you entering?: ";
      cin &gt;&gt; scores;
  
      anArray = new double[scores];
  
      cout &lt;&lt; "Enter test scores: ";
      for (count = 0; count &lt; scores; count++)
      {
          cout &lt;&lt; "Test Score " &lt;&lt; count + 1 &lt;&lt; ": ";
          cin &gt;&gt; anArray[count];
      }
  
  
      system("pause");
      return 0;
  }
  
  bool sortArray(double* anArray, int size)
  {
      for (int i = 0; i &lt; size; i++)
      {
          for (int j = 0; j &lt; size - 1; j++)
          {
              if (anArray[j] &gt; anArray[j + 1])
              {
                  int temp = anArray[j];
                  anArray[j] = anArray[j + 1];
                  anArray[j + 1] = temp;
              }
          }
      }
  }
  
  double averageArray(double* anyArray, int size)
  {
      double count = 0.0;
      for (int i = 0; i &lt; size; i++)
      {
          count += anyArray[i];
      }
      return (count / size);
  }
  </code></pre>