how to turn this into c++ code.

This is a discussion on how to turn this into c++ code. within the C++ Programming forums, part of the General Programming Boards category; 1st part:
we have an array thats n=3
index element
x[0] = 2
x[1] = 4
x[2] = 6
Sum ...

i know for the 1st part i need a loop to sum the values in the indeces then devide by n to get the average. the 2rd part is the most confusing for me as u have to subtract the average, square it and then u have to get the SumOfSquares for the 3rd part.

The best way to go about this is one step at a time. First, right the shell of the program that starts with the array already set up but does nothing. Make sure it compiles. Then, add a loop that goes through each value in the array. Maybe call cout to print the value to the screen. Make sure it compiles and runs as expected. If it doesn't, fix it. Then move on to changing the loop to get the sum. Compile, run, and fix until it is right. Next, get the average and output it. Compile, run, and fix until it is right.

Then, add another loop for the second part. Since you will need the average from part 1 inside the loop, maybe just print out the value and the previously calculated average inside this new loop (the average will be the same every time). Compile, run, and fix until it is right. At that point, you will have all the information you need to do the calculation, so just do it. You should be able to figure it out by then. If you are having lots of trouble, at least you will have a compilable program to post and ask specific questions about.

One thing to note... I'm not sure what the program is you're working on, but the ResultSquared seems a little fishy. The reason is, is you take that quantity (the sum of the squares of the difference of each element and the average), and then take the square root (incidentally, this is the sqrt( ) function in <cmath>/<math.h>) of it, then you have the standard deviation. If you square it instead, I'm not sure you have anything of much statistical significance. I'm not sure if this is a concern, but you might consider looking at the requirements again.

your probly right, excuse me for my ignorance as i dont really know how the sqrt actually works. what i meant is i need to take the square root of 4 which gives u 16 u know that symbols that looks like this
... /-----
\/ 4 =16 right? ignore the dots lol