Hello, first time posting here. Have some experience programming but relatively new. I have this program that takes a list of numbers from a .txt file and finds the mean, root-mean-square and then finally I need to find the difference between the largest and smallest values. The problem arises with the if else statement to find the largest and smallest values. The program returns no errors when compiled but does not run. The output screen is just blank with a blinking cursor. Can anyone help? Thanks in advance.
#include<iostream> // header which contains the functions needed for input and output
using namespace std;
#include<fstream>
#include<math.h>
int main()
{
ifstream infile("xxxx3padata.txt", ios::in);
infile>>data;
while(! infile.eof()) //loop to run data from text file
{
sum=sum+fabs(data); //computes sum to use for mean
Rqsum=Rqsum+pow(data,2); //computes numerator for RMS avs
//loop to find largest and smallest numbers
if(data<smallest)
{
smallest=data;
}
else if(data>largest)
{
largest=data;
}
}
mean=sum/56;
Rq=sqrt((Rqsum)/56);
diff=largest-smallest;
//output to user
cout<<"Arithmetic mean value: "<<mean<<endl;
cout<<"RMS average: "<<Rq<<endl;
cout<<"The difference between peaks is "<<diff<<endl;
}