100% found this document useful (1 vote)
14 views1 page

Standard Deviation Calculation in C

This C program calculates the standard deviation of 5 numbers entered by the user. It uses a function called "calc" to calculate the sum, average, and standard deviation of the numbers, passing the values by reference. The main function gets the user input, calls the calc function, and prints out the sum, average, and standard deviation.

Uploaded by

ahmad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
14 views1 page

Standard Deviation Calculation in C

This C program calculates the standard deviation of 5 numbers entered by the user. It uses a function called "calc" to calculate the sum, average, and standard deviation of the numbers, passing the values by reference. The main function gets the user input, calls the calc function, and prints out the sum, average, and standard deviation.

Uploaded by

ahmad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//this programme to calculate standard deviation

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

int calc (float a, float b, float c, float d, float e, float *sum, float
*avg,float *sd);

int main()
{
float a, b, c, d, e, sum=0.0, avg=0.0;

float sd=0.0;

printf("Enter Five Numbers:");


scanf("%f %f %f %f %f",&a,&b,&c,&d,&e);

calc (a, b, c, d, e, &sum, &amp;avg, &sd);

printf("\nSum=%f", sum);
printf("\nAverage=%f", avg);

printf("\nStandard Deviation=%f\n", sd);

getchar();

return 0;
}

calc (float a, float b, float c, float d, float e, float *sum, float *avg, float
*sd)

{
float Calc=0.0;

*sum = a+b+c+d+e;

*avg = *sum / 5.0;

Calc += ( a - *avg) * ( a - *avg);

Calc += ( b - *avg) * ( b - *avg);

Calc += ( c - *avg) * ( c - *avg);


Calc += ( d - *avg) * ( d - *avg);

Calc += ( e - *avg) * ( e - *avg);

*sd = sqrt((double)Calc/5.0);

You might also like