March 3rd, 2013, 04:43 PM
Re: Odd error from VS 2010 C++
Working on the program you originally posted, your calculations are wrong because to compute the average and uncertainty you are using n. n is the index for the for loop. When the for loop exits, n will be one more than first (ie 1 more than the numbers summed). Instead of using n in the calculation, use first.
You are also reading the first value at the start of the program so this won't be added to the sum
Usual practice is to set min to be greater than the max value and max to be less than the min value. Or by using the predefined constants in limits.h and float.h you could set
in >> currentvalue;
min = currentvalue;
max = currentvalue;
Hope this helps you to get the right answer!
max = DBL_MIN,
min = DBL_MAX,
Click Here to Expand Forum to Full Width