### Mean and Standard deviation

<deleted>
Last edited on
`incomeArray[0] = incomeArray[0] / (incomeArray - 1); `

I'm not sure what your intent was for incomeArray - 1. Maybe you intended (arraySize - 1)?
I really can't believe your professor expects you to do standard deviation without the use of a math library. The process involves taking the square root of the numbers.
 `` `` ``incomeArray[0] = incomeArray[0] / (incomeArray - 1); ``

When you say incomeArray, you are not getting the number of elements in it (13) like you seem to be trying to do. Instead, it returns the address in memory of the first element of the array, and attempts to divide incomeArray[0] by that. Just change (incomeArray - 1) to (arraySize - 1) and it'll work.

As for standard deviation, you should be able to find the formula online. It's just sqrt(sum((X-Xbar)^2)/N-1), where Xbar is the mean value of X and N is the number of values. You can get the sum((X-Xbar)^2) part with a loop; the hard part will be square rooting it without the math library.

Edit: As stated above, it's completely ridiculous that your professor would want you to compute the square root of something without the math library. You should see if this is actually what he intends.
Last edited on
Thanks for the feedback! I'd had the average working before then it stopped, I changed some variable and array names so looks like when I updated the variable names I changed that to the wrong new name.

In today's lecture he introduced using header files and additional cpp files and referencing them in the main cpp file, and showed us where to find the additional libraries, so seems like now we could use the math library. I'll check with him. Thanks again for the help.
Last edited on
Topic archived. No new replies allowed.