-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspearman Rank Correlation Using C Programming .c
51 lines (48 loc) · 1.36 KB
/
spearman Rank Correlation Using C Programming .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
47
48
49
50
51
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int judge_1[10],judge_2[10],judge_3[10],difference,sum=0,rank_1_and_2,rank_2_and_3,rank_1_and_3;
system("clear");
printf("Enter Ranks by Judge One \n :");
for(int i=0;i<8;i++){
scanf("%d",&judge_1[i]);
}
printf("Enter Ranks by Judge Two \n :");
for(int i=0;i<8;i++){
scanf("%d",&judge_2[i]);
}
printf("Enter Ranks by Judge Three \n :");
for(int i=0;i<8;i++){
scanf("%d",&judge_3[i]);
}
for(int i=0;i<8;i++){
difference=judge_1[i]-judge_2[i];
sum=sum+pow(difference,2);
rank_1_and_2= 1- ((6*sum)/(8*63));
}
sum=0;
for(int i=0;i<8;i++){
difference=judge_2[i]-judge_3[i];
sum=sum+pow(difference,2);
rank_2_and_3= 1- ((6*sum)/(8*63));
}
sum=0;
for(int i=0;i<8;i++){
difference=judge_1[i]-judge_3[i];
sum=sum+pow(difference,2);
rank_1_and_3= 1- ((6*sum)/(8*63));
}
if((rank_1_and_2>rank_1_and_3)&&(rank_1_and_2>rank_2_and_3)){
printf("Judge One and two have nearest Approach\n");
}
else if((rank_1_and_3>rank_1_and_2)&&(rank_1_and_3>rank_2_and_3)){
printf("Judge One and Three have nearest Approach\n");
}
else if((rank_2_and_3>rank_1_and_2)&&(rank_2_and_3>rank_1_and_3)){
printf("Judge two and three have the nearest Approach\n");
}
else {
printf("All the Judges have same approach\n");
}
}