//assumed mean method
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
/* mvx--Middle value of observation(x)
xup--Upper point of observation
xlow--Lower point of observation
f--frequency of observation
Tf--Total of frequency
n--number of observation
a--Assumed mean
c--class length
d--difference of observation and assumed mean
fd--multiplication of frequency and difference
Tfd--total of fd
mean--finally mean */
int mvx[100],xup[100],xlow[100],f[100],Tf=0,n,i,a,c,d[100],fd[100];
float mean,Tfd=0;
printf("\t\tProgram to find mean with assumed mean method:\n\n");
printf("Enter the number of observation:");
scanf("%d",&n);
printf("Enter the data:\n");
printf("X-->");
for(i=1;i<=n;i++)
{
printf("\t");
//taking data from user:
scanf("%d",&xlow[i]);
scanf("%d",&xup[i]);
}
printf("Printing the observation:\n");
for(i=1;i<=n;i++)
{
//just printing data
printf("%d-%d\t",xlow[i],xup[i]);
}
printf("\nMV(x)-->");
for(i=1;i<=n;i++)
{
//finding middle value of x amd prntfing it
mvx[i]=xup[i]+xlow[i]/2;
printf("\t%d",mvx[i]);
}
printf("\nEnter the frequency:\n");
printf("F-->");
for(i=1;i<=n;i++)
{
//taking frequency from user and making total of it
printf("\t");
scanf("%d",&f[i]);
Tf=Tf+f[i];
}
//finding class length
c=xup[1]-xlow[1];
//assuming mean from the user
printf("Assume any observation from data:");
scanf("%d",&a);
printf("D-->");
for(i=1;i<=n;i++)
{
//calculating d and printing
printf("\t");
d[i]=(mvx[i]-a)/c;
printf("%d",d[i]);
}
printf("\nFD-->");
for(i=1;i<=n;i++)
{
//calculating fd and printing
fd[i]=f[i]*d[i];
printf("\t%d",fd[i]);
Tfd=Tfd+fd[i];
}
//calculating mean
mean=a+(Tfd/Tf)*c;
printf("\nMean of the data is:%f",mean);
getch();
}
These is a program to find the mean of continuous data with class length by assumed mean method. All the other information of variables I have added in the comment part in the program. There are 2 same errors of "declaration is not allowed here" where I have declared all variables. I have tried a lot to get rid of it but I can't so please help me to get out from that..