Fstream an Array into file and then finding it's Average and Standard Deviation

Problem solved, thanks.

Any help will be much appreciated. Thank you.
Last edited on
One problem in moments() -

1
2
3
4
for (int i = 0; i <= size; i++)
{
    total += array[i];
}


Given size is the size of the array, you are trying to access the final element of the array which doesn't exist.
(arrays start at 0 and end at 1 below how many elements)
So take out i<=size and instead just put i<size?
Anybody have any idea why my average and standard deviation is way off?
In the moments() function you are using local variables (ave and stdDev) .
These are only available in the moments function and do not affect/change the variables of the same name in the mainfunction.
You should pass these variables by reference or by pointer
Topic archived. No new replies allowed.