How do I get the results to print onto a new line so the average arent one after another?
code
*/
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
float rowAverage(float num1, float num2,float num3,float num4,float num5)
{
float sum=(num1+num2+num3+num4+num5);
float avg=sum/5.0;
return avg;
}
int main()
{
string name;
float num1,num2,num3,num4,num5,avg;
ifstream fin;
fin.open("inputdata.txt");
ofstream fout;
fout.open("averages.txt");
getline(fin,name);
while(!fin.eof())
{
fin>>num1>>num2>>num3>>num4>>num5;
avg=rowAverage(num1,num2,num3,num4,num5);
if (fin.eof())
break;
fout<<avg<<endl;
}
cout<<name<<endl<<"averages.txt";
fin.close();
fout.close();
return 0;
}
*/
cout << '\n';
where you want the new line.