# Cry C++ average of numbers from file ++



## circa1525 (Nov 15, 2009)

I am trying to get my program to input 7 numbers per line from a file. find the highest number, lowest number, and their total average per line. Then out put data to new file. This is as far as I've gotten

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

int main ()

{

int counter,avg= 0,sum,limit;

ifstream infile;
ofstream outfile;
string num;

limit = 7;
sum = 0;
counter = 0;

infile.open("C:\\Temp\\myfile.txt");
if (!infile)
{
cout<<"Cannot open file, terminating program"<<endl;
exit(1);
}

outfile.open("C:\\Temp\\newfile.txt");


while(infile)

{
infile>>num;
counter++;
cout<<num<<"\t";
if (counter%7==0)
{
cout<<avg<<"\n";
}

}
infile.close();
outfile.close();

return 0;
}


----------

