title: Max, Min, Avg function for an array in C++
body: <p>I am being tasked with writing a function that takes as parameters an array of doubles, the size of the array, and then 3 pass-by-reference parameters called min, max, and avg.  My function must:  process the array data to find the minimum value (min), maximum value (max), and calculate the average (avg), each of which gets assigned to the corresponding reference parameter so that the calling function will be able to see those values. I am fairly new to coding and am very confused in what my error is the main function included below, any help would be greatly appreciated.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void normalizeMinMaxAvg(double data[], int size,double&amp; min, double&amp; 
      max, double&amp; avg)
  {
      max = 0;
      min = 0;
      //int amount = size;
      int count = 0;
      int sum = 0;
      int i;
      avg = 0;
  
      for (i=0; i &lt; size; i++)
      {
          count++;
          sum += i;
  
          if ( i &gt; max)
          {
              i=max;
          }
  
          else if (i &lt; min)
          {
              i=min;
          }
      }
      avg = sum/count;
  }
  
  int main () 
  {
      double data[]={10.0,0.0,20.0,30.0};
  
      cout &lt;&lt; normalizeMinMaxAvg (data, 4, min, max, avg);
      return 0;
  }
  </code></pre>