-
Notifications
You must be signed in to change notification settings - Fork 0
/
Four_Central_Moment 2.c
49 lines (41 loc) · 1.18 KB
/
Four_Central_Moment 2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int n,arr[100];
float mean,sum,deviation;
system("clear");
printf("How many Data You want to Enter : ");
scanf("%d",&n);
for(int i=0;i<n;i++){
printf("Enter the Value %d :",i+1);
scanf("%d",&arr[i]);
sum=sum+arr[i];
}
mean=sum/n;
// Calculation of Second Order Central Moments
for (int i = 0; i < n; i++){
sum=sum+pow((arr[i] - mean),2);
}
printf("First Order Central Moment = %f\n",sum/n);
// Calculation of Third Order Central Moments
sum=0; //
for (int i = 0; i < n; i++){
sum=sum+pow((arr[i] - mean),3);
}
printf("Third Order Central Moment = %f\n",sum/n);
// Calculation of Fourth Order Central Moments
sum=0; //
for (int i = 0; i < n; i++){
sum=sum+pow((arr[i] - mean),4);
}
printf("Fourth Order Central Moment = %f\n",sum/n);
// Calculation of Fourth Order Central Moments
sum=0; //
for (int i = 0; i < n; i++){
sum=sum+pow((arr[i] - mean),1);
}
printf("First Order Central Moment = %f\n",sum/n);
// Calculation of Fifth Order Central Moment
return 0;
}