बिजनेस मार्केटिंग का लो कॉस्ट फंडा , अपने मोबाइल से ऑटो sms भेजकर मार्केटिंग करे विजिट करे http://autotextsms.com/ बिजनेस मार्केटिंग का लो कॉस्ट फंडा http://autotextsms.com/

Search This Blog

Translate

Showing posts with label Program to calculate standard deviation using arrays by passing it to the function. Show all posts
Showing posts with label Program to calculate standard deviation using arrays by passing it to the function. Show all posts

Program to calculate standard deviation using arrays by passing it to the function

c Program to calculate standard deviation,

Program to calculate standard deviation using arrays by passing it to the function 



#include <stdio.h>
#include <math.h>
float standard_deviation(float data[], int n);
 int main()
{ int n, i; float data[100];
printf("Enter number of datas( should be less than 100): ");
 scanf("%d",&n); printf("Enter elements: ");
 for(i=0; i<n; ++i) scanf("%f",&data[i]);
printf("\n"); printf("Standard Deviation = %.2f", standard_deviation(data,n));
 return 0; }

float standard_deviation(float data[], int n)
 { float mean=0.0, sum_deviation=0.0; int i;
 for(i=0; i<n;++i) { mean+=data[i]; }
 mean=mean/n; for(i=0; i<n;++i)
 sum_deviation+=(data[i]-mean)*(data[i]-mean); return sqrt(sum_deviation/n); }


C Program example List