Write a c program to find Mean Square Deviation

Calculator in C Language with Sourc...
Calculator in C Language with Source Code | C Language Projects with Source Code 2021

How to write a c program to find Maen Square deviation in the statistic.

C code to find Mean Square Deviation

```#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

void m(int a[100]);
void mo(int a[100]);
void md(int a[100]);
float even(int a[100]);
int odd(int a[100]);
int w[100] , sum=0;
int size ,i, j, temp,  h ;
float median , m1,z,sum1=0.0;
int main()
{
int ch;

printf("\n enter the no of elements in the series : \n");
scanf("%d",&size);

printf("\n enter the elements in the series : \n");

for(i=0;i<size;i++)
{
scanf("%d",&w[i]);
}
printf("\n the elements in the series : \n");

for(i=0;i<size;i++)
{
printf("%d",w[i]);
printf("\n");
}

while (ch!=5)
{
printf("\n enter u r choice");
printf("\n press 1 for Mean");
printf("\n press 2 for Mediun");
printf("\n press 3 for Mode");
printf("\n press 4 for exit");
printf("\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
m(w);
break;
case 2:
md(w);
break;
case 3:
mo(w);
break;
case 4:
exit(0);
break;
default :
printf("\n u enter wrong choce \n");
break;
}
}
return(1);
getch();

}
void md(int  a[100])
{

for(i=0;i<size;i++)
{
for(j=i+1;j<size;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("\n the shorted series : \n");

for(i=0;i<size;i++)
{
printf("%d",a[i]);
printf("\n");
}

if(size%2==0)
{
m1=even(a);

printf("\nmedian = %.2f ",m1);
}
else
{
m1=odd(a);
printf("\nmedian = %d ",m1);

}
z=m1;
for(i=0;i<size;i++)
{
sum1=sum1+pow(a[i]-z,2);
}
sum1=sum1/size;
printf("\nThe mean squre deviation=>%.3f\n",sum1);
}

float even(int a[100])
{
int t1,t2;
t1=size/2;
t2=t1+1;
median=(float)(a[t1-1]+a[t2-1])/2;
return(median);
}

int ood (int a[100])
{
int t1;
t1=(size+1)/2;
median=a[t1-1];
return(median);
}

void m(int a[100])
{
for(i=0;i<size;i++)
{
sum=sum+a[i];
}
z=(float)sum/(size);
for(i=0;i<size;i++)
{
sum1=sum1+pow(a[i]-z,2);
}
sum1=sum1/size;
printf("\nThe mean squre deviation=>%.3f\n",sum1);
}
void mo(int a[100])
{
int s;
printf("\n the data in series are = \n");
for(i=0;i<size;i++)
{
printf("%d\n",a[i]);
}
printf("\nNow the mode of the individual series is the no whose appearing most of the time");
printf("\nSo it is clear from the display table that mode of that series is = ");
scanf("%d",&s);
z=(float)s;
for(i=0;i<size;i++)
{
sum1=sum1+pow(a[i]-z,2);
}
sum1=sum1/size;
printf("\nThe mean squre deviation=>%.3f\n",sum1);
}

```