Standard Deviation Program in C
#include<stdio.h>
#include <math.h>
float standard_deviation(float data[]);
int main()
{
int i;
float arr[10];
printf("Enter the elements: ");
for(i=0; i < 10; ++i)
scanf("%f", &arr[i]);
printf("\nStandard Deviation = %.6f", standard_deviation(arr));
return0;
}
float standard_deviation(float arr[])
{
float sum = 0.0, mean, standDev = 0.0;
int i;
for(i=0; i<10; ++i)
{
sum += arr[i];
}
mean = sum/10;
for(i=0; i<10; ++i)
standDev += pow(arr[i] - mean, 2);
return sqrt(standDev/10);
}
Output:-
