Calculating Standard Deviation & Variance in C++

As the other answer by horseshoe correctly suggests, you will have to use a loop to calculate variance otherwise the statement var = ((Array[n] – mean) * (Array[n] – mean)) / numPoints; will just consider a single element from the array. Just improved horseshoe’s suggested code: Your sum works fine even without using loop because … Read more