Define a function that takes an array as its argument and returns the standard deviation of the array. The function should have at least two arguments, an array parameter and a type int parameter that gives the number of array position used. You may define the function either as a valued function or void function.
one problem is what oghmaosiris said. Try mean2=mean(x,10); before calling deviation(x,10). another problem (inside both mean and deviation functions) is this: for ( int i = 0; i <=size; i++ ). it should be like this: for ( int i = 0; i < size; i++ ) (you should use '<' and not '<=')
I believe that if you take care of these two things your program will run fine! :)
Here is a suggestion for future reference. Use constants. Use the constant for all of your array loops. If the program ever needs to change you can simply change the value of the constant.
1 2 3 4 5 6 7 8 9 10
constint SIZE=10;
double x[SIZE];
mean2=0;
cout << "Enter ten numbers: ";
for (int i=0; i < SIZE; i++)
{
cin>>x[i];
}
The other suggestions are good as well. mean2 shouldn't be a global. It is a better practice to declare variables at the lowest possible scope.