# C Program to Calculate Standard Deviation

#### In this example, you will learn to calculate the standard deviation of 10 numbers using arrays.

This program calculates the standard deviation of an individual series using arrays. Visit this page to learn about Standard Deviation.

To calculate the standard deviation, we have created a function named `calculateSD()`.

## Program to Calculate Standard Deviation

``````
#include <math.h>
#include <stdio.h>
float calculateSD(float data[]);
int main(){
int i;
float data;
printf("Enter 10 elements: ");
for (i = 0; i < 10; ++i)
scanf("%f", &data[i]);
printf("nStandard Deviation = %.6f", calculateSD(data));
return 0;
}

float calculateSD(float data[]){
float sum = 0.0, mean, SD = 0.0;
int i;
for (i = 0; i < 10; ++i) {
sum += data[i];
}
mean = sum / 10;
for (i = 0; i < 10; ++i)
SD += pow(data[i] - mean, 2);
return sqrt(SD / 10);
}
``````

Output

```Enter 10 elements: 1
2
3
4
5
6
7
8
9
10

Standard Deviation = 2.872281
```

Here, the array containing 10 elements is passed to the `calculateSD()` function. The function calculates the standard deviation using mean and returns it.

## C Example for Beginners: C Program to Calculate Standard Deviation

#### Free Machine Learning & Data Science Coding Tutorials in Python & R for Beginners. Subscribe @ Western Australian Center for Applied Machine Learning & Data Science. ```