1: #include<stdio.h>
2: #include<conio.h>
3: #include<math.h>
4: void main()
5: {
6: float x[50];
7: int n,i;
8: float sumx=0,sumx2=0;
9: float var,mean,sd;
10: printf("Number of elements in an array:");
11: scanf("%d",&n);
12: printf("\nEnter the elements:\n");
13: for(i=0;i<n;i++)
14: {
15: scanf("%f",&x[i]);
16: sumx=sumx+x[i];
17: sumx2=sumx2=x[i]*x[i];
18: }
19: mean=sumx/n;
20: var=1.0/n*(sumx2-(mean*mean));
21: sd=sqrt(var);
22: printf("\nThe array is:\n");
23: for(i=0;i<n;i++)
24: printf("%.2f ",x[i]);
25: printf("\nIts mean = %.2f \nvariant = %.2f\nStd deviation =%.2f\n",mean,var,sd);
26: getch();
27: }
No comments:
Post a Comment