Mode = 2 = median
Mean: 4.2 Median: 2 Mode: 1 Range: 8
Median: 3 Mode: 1 Range: 6
#include<stdio.h> #define MAXVAL 1000 void sort1(int a[],int n); void median(int a[],int n); void mode(int a[],int n); int main() { int n; int arr[MAXVAL]; int i; printf("Enter the number of elements:"); scanf("%d",&n); printf("Enter the values:"); for(i=0;i<n;i++) { printf("a[%d]=",i); scanf("%d",&arr[i]); } sort1(arr,n); median(arr,n); mode(arr,n); } void sort1(int a[],int n) { int i; int j; int temp; for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } } void median(int a[],int n) { int median; int mid; if((n%2)==0) { mid=n/2; median=(a[mid-1]+a[mid])/2; } else { mid=(n+1)/2; median=a[mid-1]; } printf("The median is:%d\n",median); } void mode(int a[],int n) { int i; int count1[MAXVAL]; for(i=0;i<n;i++) { count1[i]=0; } for(i=0;i<n;i++) { count1[a[i]]++; } i--; int mode=count1[0]; int j; int k; int flag=0; for(j=0;j<=a[i];j++) { if(count1[j]>count1[mode]) mode=j; } for(j=0;j<=a[i];j++) { for(k=j+1;k<=a[i];k++) { if(count1[j]=count1[k] && count1[j]>count1[mode]) { flag=1; } } } if(flag==1) { printf("Mode cannot be calculated"); } else printf("the Mode is:%d",mode); }
Mean: 4.2 Median: 2 Mode: 1 Range: 8
1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 6, 8, 10, 12 The mean is 4 The median is 2.5 The mode is 1
Mean = 2.125 Median = 1.5 Mode = 1 and 2.
mean= 2, mode= 1 and 3, median= 3, and range= 2
Mean: 4.2 Median: 2 Mode: 1 Range: 8
Median: 3 Mode: 1 Range: 6
#include<stdio.h> #define MAXVAL 1000 void sort1(int a[],int n); void median(int a[],int n); void mode(int a[],int n); int main() { int n; int arr[MAXVAL]; int i; printf("Enter the number of elements:"); scanf("%d",&n); printf("Enter the values:"); for(i=0;i<n;i++) { printf("a[%d]=",i); scanf("%d",&arr[i]); } sort1(arr,n); median(arr,n); mode(arr,n); } void sort1(int a[],int n) { int i; int j; int temp; for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } } void median(int a[],int n) { int median; int mid; if((n%2)==0) { mid=n/2; median=(a[mid-1]+a[mid])/2; } else { mid=(n+1)/2; median=a[mid-1]; } printf("The median is:%d\n",median); } void mode(int a[],int n) { int i; int count1[MAXVAL]; for(i=0;i<n;i++) { count1[i]=0; } for(i=0;i<n;i++) { count1[a[i]]++; } i--; int mode=count1[0]; int j; int k; int flag=0; for(j=0;j<=a[i];j++) { if(count1[j]>count1[mode]) mode=j; } for(j=0;j<=a[i];j++) { for(k=j+1;k<=a[i];k++) { if(count1[j]=count1[k] && count1[j]>count1[mode]) { flag=1; } } } if(flag==1) { printf("Mode cannot be calculated"); } else printf("the Mode is:%d",mode); }
Mean: 4.2 Median: 2 Mode: 1 Range: 8
The mean is 4.25, the median is 3.5 and the modes are 1 and 2.
You are right. 1 is the median.The median of a set of data is found by arranging the data in increasing or decreasing order. So, we can arrange the items: 0, 1, 1, 1, 4, 4If the number of items of data is even, as it is in this case, then the median is the average (or mean) of the two middle numbers. So, the median is (1 + 1)/2 = 2/2 = 1If the number of items of data is odd, then the median is the middle number in the ordered set. For example the median of the data 1, 3, 3, 5, 6, 8, 9 is 5, because 5 is in the middle.It is also the mode. The mode of a set of data is the one item of data that occurs most often. 1 has the highest number of frequency in this sample. Thus 1 is the mode also.
1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 6, 8, 10, 12 The mean is 4 The median is 2.5 The mode is 1
Mean = sum of observations/number of observations Median: Order the observations. Of there are an odd number of observations, the median is the middle one. So if there are n observations (where n is odd) then the median is the (n+1)/2 th observation. If n is even, the median is the average of the n/2 th observation and the (n/2 +1) th. Mode: Group the observations. The mode is the value or values that appear the most often. There may be no mode, a single mode or lots of them.
mode- 5 median- 5 mean- 4.8
Mean = 21.6 Median = 19.5 Mode = 20 and 21 ------------------------------------------------------------------------ If the "2 1" (between 18 and 20 at the end) is supposed to be "21" then Mean = 26 Median = 20 Mode = 20