Hey All,

I am stuck! Why in the world does this calculate the estimated(population) variance rather than the actual variance:

Code:

double calculateVariance(StudentsGrades obj[], double meanAvg)
{
double variance;
for(int index = 0; index < MAX_NUM_STUDENTS; index++)
{
if((obj[index].getStudentAvg() == 0) || (obj[index].getStudentAvg() == meanAvg))
variance += 0.0;
else variance += pow(obj[index].getStudentAvg() - meanAvg, 2);
}
variance = variance / TOTAL_STUDENTS; // TOTAL_STUDENTS is one less than
// MAX_NUM_STUDENTS because
// the data file has titles for each column
return variance;
}

Any help would be appreciated. I use this function to calculate the standard deviation.

I have googled every where and can't find the solution and I have used a calculator and

MS Excel to check the numbers, and they are off.

Cheers!