Using functions properly
<p>I'm trying to use functions to process data from a .dat file, but I can't seem to get the functions to read the data correctly. On line 62, it's trying to calculate the low, high and average of the different temperatures recorded at three different heights, but the functions aren't processing any data. The average function should be dividing the total of the numbers by the count of the numbers, but it's not doing that. Plus, I can't get high or low to work. What am I doing wrong?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;iomanip&gt;
#include &lt;conio.h&gt;
#include &lt;string&gt;

using namespace std;

double qMeter = 0;
double hMeter = 0;
double oneMeter = 0;
int solDay = 0;
string garbage;
string localTime;
string decSol;
ifstream input;
ofstream output;

//function prototypes
double low(double lowTemp);
double high(double highTemp);
float average(double avgTemp);

int main()
{

input.open("curiosity234x.dat"); //opens input data file
output.open("output.dat"); //opens output data file


  for (int i = 0; i &lt; 4; i++) //gets rid of the first four lines
{
  getline(input,garbage);
  cout &lt;&lt; endl;
}

while (!input.eof())
{
    int count; 
    double newOneMeter;
    double newHMeter;
    double newQMeter;

    if (solDay == 2) //processes data for the second solar day
    {
     input &gt;&gt; solDay &gt;&gt; localTime &gt;&gt; decSol 
     &gt;&gt; newOneMeter &gt;&gt; newHMeter &gt;&gt; newQMeter;

     oneMeter = oneMeter + newOneMeter;
     hMeter = hMeter + newHMeter;
     qMeter = qMeter + newQMeter;
     count++;

     output &lt;&lt; solDay &lt;&lt; fixed &lt;&lt; setprecision(1) &lt;&lt; setw(5)
        &lt;&lt; "Solar" &lt;&lt; "Average" &lt;&lt; "Low" &lt;&lt; "High"
        &lt;&lt; "Average" &lt;&lt; "Low" &lt;&lt; "High" 
        &lt;&lt; "Average" &lt;&lt; "Low" &lt;&lt; "High" 
        &lt;&lt; "Day" &lt;&lt; "Temp" &lt;&lt; "Temp" &lt;&lt; "Temp" &lt;&lt; "Temp" &lt;&lt; "Temp"
        &lt;&lt; "Temp" &lt;&lt; "Temp" &lt;&lt; "Temp" &lt;&lt; "Temp"
        &lt;&lt; fixed &lt;&lt; setprecision(15) &lt;&lt; "1 meter" &lt;&lt; ".5 meters"
        &lt;&lt; ".25 meters"
        &lt;&lt; average(oneMeter) &lt;&lt; low(oneMeter) &lt;&lt; high(oneMeter)
        &lt;&lt; average(hMeter) &lt;&lt; low(hMeter) &lt;&lt; high(hMeter)
        &lt;&lt; average(qMeter) &lt;&lt; low(qMeter) &lt;&lt; high(qMeter);
    }

    if (solDay == 3) //processes data for the third solar day
    {
     input &gt;&gt; solDay &gt;&gt; localTime &gt;&gt; decSol 
     &gt;&gt; newOneMeter &gt;&gt; newHMeter &gt;&gt; newQMeter;

     oneMeter = oneMeter + newOneMeter;
     hMeter = hMeter + newHMeter;
     qMeter = qMeter + newQMeter;
     count++;

     output &lt;&lt; solDay &lt;&lt; fixed &lt;&lt; setprecision(1) &lt;&lt; setw(5)
        &lt;&lt; "Solar" &lt;&lt; "Average" &lt;&lt; "Low" &lt;&lt; "High" 
        &lt;&lt; average(oneMeter) &lt;&lt; low(oneMeter) &lt;&lt; high(oneMeter)
        &lt;&lt; average(hMeter) &lt;&lt; low(hMeter) &lt;&lt; high(hMeter)
        &lt;&lt; average(qMeter) &lt;&lt; low(qMeter) &lt;&lt; high(qMeter);
    }
  }

  cout &lt;&lt; endl &lt;&lt; "The output.dat file has been written and transmitted.";
  /*
  reads first line. Assigns first string to 'int solDay' 
  second to 'string time', third to decSol, fourth to oneMeter, 
  fifth to hMeter and sixth to qmeter. Meters should have setw().
  */
getch();
return 0;

input.close();
output.close();
}


//functions used in main
double low(double lowTemp)
{
   int test = 10,000;
   double least;

   if (lowTemp &lt; test)
   {
     lowTemp = test;
     lowTemp = least;       
    }
    return least;
}

double high(double highTemp)
{
   int test = 10,000;
   double most;

   if (highTemp &lt; test)
   {
      highTemp = test;
      highTemp = most;        
    }
   return most;
}

float average(double avgTemp)
{
   avgTemp = avgTemp / count;
   return avgTemp;
}
</code></pre>
