C Online Compiler
Example: C program to calculate Standard Deviation
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C program to calculate Standard Deviation #include <stdio.h> #include <math.h> // It's main function of the program int main() { int sd_count, i; float sum = 0.0, mean, sd_val = 0.0; printf("Tell me count of numbers to calculate the standard deviation: "); scanf("%d", &sd_count); float sd_elements[sd_count]; printf("\nEnter the %d elements:\n", sd_count); for (i = 0; i < sd_count; i++) { scanf("%f", &sd_elements[i]); sum += sd_elements[i]; } mean = sum / 10; for (i = 0; i < 10; i++) { sd_val += pow(sd_elements[i] - mean, 2); } // Final output of the program printf("\nStandard Deviation = %.6f\n", sqrt(sd_val / 10)); return 0; }
5 10 30 50 70 90
Output
Clear
ADVERTISEMENTS