AIM:A program to find the standard deviation using functions.
PROGRAM:
#include<stdio.h>
main()
{
int n,x[100],s;
printf("enter the value of n");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&x[i]);
s=pas(x,n);
printf("standard deviation=%f",s);
}
pas(x,n)
{
int x[100],n;
int sum=0,vsum=0,i,k;
{
float mean,sd;
for(i=0;i<n;i++)
sum=sum+x[i];
mean=sum/n;
for(i=0;i<n;i++)
vsum=vsum+(x[i]-mean*x[i]-mean);
k=vsum/n;
sd=sqrt(k);
return(sd);
}
}
OUTPUT:
enter the value of n
Use math.h in this programme otherwise it doesn't run.😋😋
ReplyDelete