title: Using a function to find the average of an array C++
body: <p>the purpose of this task is to find the average of an array but not within the main, I have to call a function to do the sum and show the average. </p>
  
  <p>I though my code was sound but it just returns " the average is 011014F1"</p>
  
  <p>I have tried a few different ways of doing the function but I've gone wrong somewhere, maybe everywhere!</p>
  
  <p>Just a heads up, im just starting out with programing.</p>
  
  <p>Heres my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  
  void printArray(int theArray[], int sizeOfarray);
  float average(float numbers[], float size, float arrayAverage);
  
  int main()
  {
  
     int array[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  
     printArray(array, 10);
  
     cout &lt;&lt; "The average is: " &lt;&lt; average &lt;&lt; endl;
  
     return 0;
  }
  
  void printArray(int theArray[], int sizeOfarray)
  {
     for (int x = 0; x &lt; sizeOfarray; x++)
    {
      cout &lt;&lt; theArray[x] &lt;&lt; endl;
  
    }
  }
  
  float average(float numbers[], float size, float arrayAverage)
  {
          double sum = 0.0;
          for (int x = 0; x &lt; size; x++)
      {
          sum += numbers[x];
          arrayAverage = sum / size;
      }
          return (arrayAverage);
  }
  </code></pre>
  
  <p>I had the float average function initially set as a float with int for 'numbers', 'size' and 'arrayAverage' but thought i would change them all to float so they dont clash. like converting an int to a float etc..</p>
  
  <p>As i said im new to this so my logic is not really there but i think im n the right tracks.</p>
  
  <p>Any idea why its returning 011014F1 and numbers like that instead of just the average of 1-10?</p>
  
  <p>Any tips much appreciated!</p>