15 Ocak 2015 Perşembe

Standard deviation calculation


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

int main()
{
int  xxx;
printf(" tell me number of array=");
scanf("%d",&xxx);

float total=0.0;
float xscores[100];
float xdeviation=0.0;
int xcounter;
float  avg,burcin,xburcin,xxburcin;
for ( xcounter=0;xcounter<xxx;xcounter++)
{
scanf("%f",&xscores[xcounter]);
}
for (xcounter=0;xcounter<xxx;xcounter++)
{
printf("the number at %d is %3.1f \n",xcounter+1,xscores[xcounter]);
total=total+xscores[xcounter];
}
printf("\n sum of array=%3.1f",total);
avg=total/(float)xxx;
printf("\n avg of array=%3.2f",avg);

for (xcounter=0;xcounter<xxx;xcounter++)
{
xdeviation=(xscores[xcounter]-avg);
burcin+=xdeviation*xdeviation;

}
xburcin=(burcin/(float)xxx);
xxburcin=sqrt(xburcin);
printf("\n standard deviation= %3.1f",xxburcin);
getch();
return 0;
}

Standard deviation not resolved.


12 Ocak 2015 Pazartesi