Define the function to calculate standard deviation
We'll start by defining a function that takes an array of float values and returns the standard deviation of those values.
float SD(float values[]) // function for calculating standard deviation
{
float sum = 0.0, mean, sd = 0.0;
int i;
for(i = 0; i < 10; ++i)
{
sum = sum + values[i]; // calculating sum
}
mean = sum/10; // finding mean.
for(i = 0; i < 10; ++i)
sd = sd + pow(values[i] - mean, 2); // calculating standard deviation
return sqrt(sd / 10);
}
In this function, we first calculate the sum of all the values. We then divide the sum by the total number of values to get the mean. Next, we calculate the variance by summing up the squared differences of each value from the mean. After that, we calculate the standard deviation by taking the square root of the variance.