I am having a problem solving this. I dont know what i am doing wrong

Im trying to do this function and i dont know why it isnt running.

#include <iostream>
#include <fstream>

using namespace std;

float findavg();
int findtrunc();
int findround();

ifstream infile;
ofstream outfile;

int main ()
{
float avgnum;
int truncnum;
int roundnum;

infile.open("truncandroundin.txt");
outfile.open("truncandroundout.txt");

truncnum= findtrunc();
roundnum= findround();*/
avgnum= findavg();

outfile <<"The Average for the number is "<<avgnum<<endl;
outfile <<"The trunc for the number is " <<truncnum<<endl;
outfile <<"The round of the number is " <<roundnum<<endl;


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

system("pause");
return 0;
}
//Beginning of Average
float findavg()
{
float floatval, sum=0.0, sentinel, average;
int count=0;

infile>>floatval>>sentinel;

while(floatval !=sentinel)
{sum = sum + floatval;
count++;

infile>>floatval;
}

if(count)
average = sum/count;
else
average= -999999.0;
return average;
}//End of Average
//Begin Trunc Function
int findtrunc()
{
float floatval, sentinel;
int count = 0, trunc;

infile>>floatval>>sentinel;

while(floatval !=sentinel)
{
trunc=static_cast<int>(floatval);
count++;
infile>>floatval>>sentinel;
}
return trunc;
}//End of Trunc
//Beginning of Round
int findround()
{
float floatval, sentinel, sum=0.0;
float round, num;
int count = 0;

infile>> floatval>>sentinel;

while (floatval !=sentinel)
{
sum = sum + floatval;
round = floatval + .05;
num= round;

round= static_cast<int>(num);
count++;
infile>> floatval>>sentinel;
}
return round;
}
Last edited on
roundnum= findround();*/
The */ initializes a block comment that never closes.
Life saver. Thanks.
Topic archived. No new replies allowed.