Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

C program to calculate standard deviation

YASH PAL, 31 July 2024

In this tutorial, we are going to write a C Program to calculate standard deviation in C Programming with practical program code and step-by-step full complete explanation.

C Program to calculate standard deviation

C Program to calculate the standard deviation.

 
#include<stdio.h>
#include<conio.h>
#include<math.h>

#define MAXSIZE 100

void main()
{
    int i,n;
    float value[MAXSIZE], deviation;
    
    int sum,sumsqr,n=0;
    
    float mean, variance, stddeviation;

    printf("Input values: input -1 to endn");

    for(i=1;i<MAXSIZE;i++)
    {
        scanf("%f",&value[i]);

        if(value[i]== -1)
            break;
        sum += value[i];
        n+=1;
    }

    mean=sum/(float)n;

    for(i=1;i<=n;i++)
    {
        deviation = value[i]-mean;
        sumsqr += deviation*deviation;
    }

    variance = sumsqr/(float)n;
    stddeviation=sqrt(variance);

    printf("nNumber of items: %d",n);
    printf("nMean: %f",mean);
    printf("nStandard deviation: %f",stddeviation);
}

Output

 
Input values: input -1 to end
65 9 27 78 12 20 33 49 -1

Number of items: 8
Mean: 36.625000
Standard deviation: 23.510303
c coding problems

Post navigation

Previous post
Next post
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
  • Hackerrank Day 14 scope 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes