NEED HELP: reading file and finding average and stdv

I keep getting stuck trying to find the average and standard deviation because i cant get my program to read the file correctly. please tell me what im doing wrong.

#include <iostream>
#include <fstream>
using namespace std;

void readData();
void calculateStats();
void saveResults();
int number;
int main()
{
readData();

return 0;
}
void readData(int)
{
ifstream inputFile;

inputFile.open("datatable.txt");
while (inputFile >> number)
{
cout << number<< endl;
}
inputFile.close();

}
I had to format your code just to be able to read it.
Youll get more help if you use code tags.

http://www.cplusplus.com/articles/jEywvCM9/

Not sure what your doing but try to change
void readData(int)
to
void readData()

It worked for me.

Ok i fixed that, im trying to find the sum and my numbers are not the same as in my data table

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;

void readData();
void calculateStats();
void saveResults();
int value=0;
int numbers=0;
int count=0;
double sum = 0;
int main()
{
	readData();

	return 0;
}
void readData()
{
	ifstream inputFile;

	inputFile.open("datatable.txt");
	while (inputFile >> value)
	{
		cout << value << endl;
		numbers++;
		sum += value;
		cout << "sum" << sum;
	}
	inputFile.close();

}
Topic archived. No new replies allowed.