C Program to Calculate Standard Deviation

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:-

2 comments

  1. Normally I don’t read article on blogs, but I would like to say that this write-up very forced me to try and do it! Your writing style has been amazed me. Thanks, very nice article.

Leave a Reply

Your email address will not be published. Required fields are marked *