1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
float rowAverage(float val1, float val2, float val3, float val4, float val5)
{
float sum = val1 + val2 + val3 + val4 + val5;
float average = sum / 5.0;
return average;
}
int main()
{
ifstream input("inputData.txt");
ofstream output("averages.txt");
float average, val1, val2, val3, val4, val5;
//string fname, lname;
//getline(fname, lname);
while(!input.eof())
{
input >> val1 >> val2 >> val3 >> val4 >> val5;
rowAverage(val1, val2, val3, val4, val5);
output << rowAverage;
}
output.close();
input.close();
cout << "done";
return 0;
}
| |