Function practice 3
This practice problem will require you to programme basic functions.
You are required to write a function that calculates the mean and standard deviation of an array.
\(s = \sqrt{\sum^N_{i=1}(x_i-\overline{x})^2 / (N-1)}\)
It is recommended that your functions are defined as follows (C++)
double mean(double a[], int size);
double stdd(double a[], int size);
// size is the total amount of elements in your array a.
It is recommended that your functions are defined as follows (C++)
float mean(a):
# do your stuff
float stdd(a):
# do your stuff
// size is the total amount of elements in your array a.
Input Specification
The first line will contain a single integer \(N\) (\(1 < N < 10000\)), indicating the number of elements inside the array.
The following line will contain \(N\) numbers, each a member of the array.
Output Specification
The output should contain one line, with mean value and standard deviation separated by space. Each number should be accurate only to 2 digits after decimal point.
Hint: To output 2 digits after the decimal point, do these:
std::cout << std::fixed;
std::cout << std::setprecision(2);
std::cout << d;
Sample Input
5
7.0866983372921615 5.276190476190476 52.11538461538461 21.75681570338059 269.3333333333333
Sample Output
71.11 112.39
Comments