I saved the file \"test.txt\" in the following format in the same directory as t
ID: 3644689 • Letter: I
Question
I saved the file "test.txt" in the following format in the same directory as the program1.3
2.3
1.2
3.45
6.78
2.34
The program just keeps running, no cmd prompt. no errors.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inputfile;
inputfile.open("test.txt");
double sum = 0,value;
int count=0;
while(!inputfile.eof())
{
inputfile >> value;
sum+= value;
count++;
}
double avg = sum/count;
cout << "The Average of the numbers : " << avg << endl;
system("pause");
return 0;
}