#define SIZE 100
#include"stdio.h"
float mean_function(float[],int);
float median_function(float[],int);
float mode_function(float[],int);
int main()
{
int i,n,choice;
float array[SIZE],mean,median,mode;
printf("Enter No of Elements\n");
scanf("%d",&n);
printf("Enter Elements\n");
for(i=0;i
scanf("%f",&array[i]);
do
{
printf("\n\tEnter Choice\n\t1.Mean\n\t2.Median\n\t3.Mode\n4.Exit");
scanf("%d",&choice);
switch(choice)
{
case 1: mean=mean_function(array,n);
printf("\n\tMean = %f\n",mean);
break;
case 2: median=median_function(array,n);
printf("\n\tMedian = %f\n",median);
break;
case 3: mode=mode_function(array,n);
printf("\n\tMode = %f\n",mode);
break;
case 4: break;
default:printf("Wrong Option");
break;
}
}while(choice!=4);
}
/***************************************************************
Function Name : mean_function
Purpose : to find mean
Input : array of elements,no of elements
Return Value : Mean
Return Type : Float
****************************************************************/
float mean_function(float array[],int n)
{
int i;
float sum=0;
for(i=0;i
sum=sum+array[i];
return (sum/n);
}
/***************************************************************
Function Name : median_function
Purpose : to find median
Input : array of elements,no of elements
Return Value : Median
Return Type : Float
****************************************************************/
float median_function(float a[],int n)
{
float temp;
int i,j;
for(i=0;i
for(j=i+1;j
{
if(a[i]>a[j])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
if(n%2==0)
return (a[n/2]+a[n/2-1])/2;
else
return a[n/2];
}
float mode_function(float a[],int n)
{
return (3*median_function(a,n)-2*mean_function(a,n));
}
#include"stdio.h"
float mean_function(float[],int);
float median_function(float[],int);
float mode_function(float[],int);
int main()
{
int i,n,choice;
float array[SIZE],mean,median,mode;
printf("Enter No of Elements\n");
scanf("%d",&n);
printf("Enter Elements\n");
for(i=0;i
scanf("%f",&array[i]);
do
{
printf("\n\tEnter Choice\n\t1.Mean\n\t2.Median\n\t3.Mode\n4.Exit");
scanf("%d",&choice);
switch(choice)
{
case 1: mean=mean_function(array,n);
printf("\n\tMean = %f\n",mean);
break;
case 2: median=median_function(array,n);
printf("\n\tMedian = %f\n",median);
break;
case 3: mode=mode_function(array,n);
printf("\n\tMode = %f\n",mode);
break;
case 4: break;
default:printf("Wrong Option");
break;
}
}while(choice!=4);
}
/***************************************************************
Function Name : mean_function
Purpose : to find mean
Input : array of elements,no of elements
Return Value : Mean
Return Type : Float
****************************************************************/
float mean_function(float array[],int n)
{
int i;
float sum=0;
for(i=0;i
sum=sum+array[i];
return (sum/n);
}
/***************************************************************
Function Name : median_function
Purpose : to find median
Input : array of elements,no of elements
Return Value : Median
Return Type : Float
****************************************************************/
float median_function(float a[],int n)
{
float temp;
int i,j;
for(i=0;i
for(j=i+1;j
{
if(a[i]>a[j])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
if(n%2==0)
return (a[n/2]+a[n/2-1])/2;
else
return a[n/2];
}
float mode_function(float a[],int n)
{
return (3*median_function(a,n)-2*mean_function(a,n));
}
Output
--------------
Enter Elements
2
3
4
Enter Choice
1.Mean
2.Median
3.Mode
4.Exit
1
Mean = 3.000000
Enter Choice
1.Mean
2.Median
3.Mode
4.Exit
2
Median = 3.000000
Enter Choice
1.Mean
2.Median
3.Mode
4.Exit
3
Mode = 3.000000
Enter Choice
1.Mean
2.Median
3.Mode
4.Exit
4
-------------------
Enter No of Elements
4
Enter Elements
9 8 7 6
Enter Choice
1.Mean
2.Median
3.Mode
4.Exit
1
Mean = 7.500000
Enter Choice
1.Mean
2.Median
3.Mode
4.Exit
2
Median = 7.500000
Enter Choice
1.Mean
2.Median
3.Mode
4.Exit
3
Mode = 7.500000
Enter Choice
1.Mean
2.Median
3.Mode
4.Exit
Mean,Median,Mode program that you written is not working.Median is correct but what about mean and mode???????
ReplyDeleteThe modified program that i written is.......
Ohh i can't post that pgm...if anyone want that pgm just post your e-mail id here i will send it u.......
ReplyDeleteyes sir...i need that...could you please send it to me at : jinuhaneef@gmail.com
Deleteyes frind please please mail me at : hellopankajin@rediff.com
ReplyDeleteyes post me on peace75@ymail.com
ReplyDeletem id is diomond_flower20@yahoo.com
ReplyDeletecan you help me in my ass to create a program that will get mean, median, mode... i saw this program in your site but i cant understand.. can you help me please???
ReplyDeleteFRANCIS ARBY P. POJADAS
(emo_revenge2007@yahoo.com)
yes post me at rogueindia@gmail.com
ReplyDeleteTry to get programs at : http://glearn.net
ReplyDeleteplease email me at LCook122@gmail.com
ReplyDeleteplease email me at aray1427@yahoo.com
ReplyDeletethanks..
please email me at cen-111@hotmail.com
ReplyDeleteplease email me at jjrotcamative@hotmail.com
ReplyDeletepls send the program to me: seguntaiwoojo@gmail.com
ReplyDeleteCan make a program of this problem?
ReplyDeleteCreate a program that will ask the user for n numbers then get the Median, the Mean and the
Mode.
i. The Mean is simply the average of the numbers.
ii. The Mode is the most frequent occurring number. It is important to note that there can be
more than one mode and if no number occurs more than once in the set, then there is no mode
for that set of numbers.
iii. The Median is the middle value. When n is odd, the median is the middle entry in the list after
sorting the list into increasing order. When n is even then the median is equal to the sum of the
two middle (after sorting the list into increasing order) numbers divided by two.
Sample output (n is odd):
Enter n: 5
n1: 15
n2: 18
n3: 22
n4: 15
n5: 24
The Mean is 18.8.
The Mode is 15.
The Median is 18.
Sample output (n is even):
Enter n: 6
n1: 15
n2: 12
n3: 3
n4: 6
n5: 5
n6: 10
The Mean is 8.5.
There is no Mode.
The Median is 8.
--Can you send this to my e-mail.. pls. gotta need you help pls..
this is my e-mail silversamurai_19@yahoo.com
pls send it to seguntaiwoojo@live.ca
ReplyDeleteplz send me at adil.officer@gmail.com
ReplyDelete