Practical No. 1 Program For Calculating Mean, Median and Mode
Practical No. 1 Program For Calculating Mean, Median and Mode
Practical No. 1 Program For Calculating Mean, Median and Mode
#include<stdio.h>
float mean_function(float[],int);
float median_function(float[],int);
float mode_function(float[],int);
void main()
float array[SIZE],mean,median,mode;
scanf("%d",&n);
printf("Enter Elements\n");
for(i=0;i<n;i++)
scanf("%f",&array[i]);
do
scanf("%d",&choice);
switch (choice)
case 1:
mean=mean_function(array,n);
printf("\n\t Mean=%f\n",mean);
break;
case 2:
median=median_function(array,n);
printf("\n\t Median=%f\n",median);
break;
case 3:
mode=mode_function(array,n);
printf("\n\t Mode=%f\n",mode);
break;
case 4:
break;
default:
printf("Wrong Option");
break;
while(choice!=4);
int i;
float sum=0;
for(i=0;i<n;i++)
sum=sum+array[i];
return(sum/n);
float temp;
int i,j;
for(i=0;i<n;i++)
for(j=i+1;j<n;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];
{return(3*median_function(a,n)-2*mean_function(a,n));
}
OUTPUT-:
PRACTICAL NO. 2
#include<conio.h>
#include<math.h>
void main()
int n,i;
float avrg,var,SD,sum=0,sum1=0;
int x[MAXSIZE];
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&x[i]) ;
for(i=0;i<n;i++)
sum=sum+x[i] ;
avrg=sum/n;
sum1=sum1+pow((x[i]-avrg),2);
var=sum1/n;
printf("\n\n\nVariance is:.2f",var);
SD=sqrt(var);
printf("\n\n\nS.D is :%2f",SD);
getch();
OUTPUT-:
PRACTICAL NO. 3
Program for calculating the Coefficient of Correlation:-
#include <stdio.h>
#include <math.h>
int main() {
scanf("%d", &n);
return 0;
OUTPUT-:
PRACTICAL NO.4
#include<conio.h>
#include<math.h>
int main()
int n,i,x[20],y[20],sumx=0,sumy=0,sumxy=0,sumx2=0;
float a,b;
scanf("%d",&n);
for(i=0;i<=n-1;i++)
scanf(" %d",&x[i]);
for(i=0;i<=n-1;i++)
scanf("%d",&y[i]);
for(i=0;i<=n-1;i++)
sumx=sumx +x[i];
sumx2=sumx2 +x[i]*x[i];
sumy=sumy +y[i];
sumxy=sumxy +x[i]*y[i];
a=((sumx2*sumy -sumx*sumxy)*1.0/(n*sumx2-sumx*sumx)*1.0);
b=((n*sumxy-sumx*sumy)*1.0/(n*sumx2-sumx*sumx)*1.0);
return(0);
OUTPUT-:
PRACTICAL NO. 5
#include<conio.h>
#include<math.h>
int main()
int n,i;
float Y[20],sumx=0,sumy=0,sumxy=0,sumx2=0,x[20],y[20];
float a,b,A;
scanf("%d",&n);
for(i=0;i<=n-1;i++)
scanf("%f",&x[i]);
for(i=0;i<=n-1;i++)
scanf("%f",&y[i]);
for(i=0;i<=n-1;i++)
{
Y[i]=log(y[i]);
for(i=0;i<=n-1;i++)
sumx=sumx +x[i];
sumx2=sumx2 +x[i]*x[i];
sumy=sumy +Y[i];
sumxy=sumxy +x[i]*Y[i];
A=((sumx2*sumy -sumx*sumxy)*1.0/(n*sumx2-sumx*sumx)*1.0);
b=((n*sumxy-sumx*sumy)*1.0/(n*sumx2-sumx*sumx)*1.0);
a=exp(A);
return(0);
OUTPUT-:
PRACTICAL NO. 6
#include "math.h"
#include "string.h"
void deviation(float *a, float mean, int n, float *d, float *S);
void main() {
char type_coff[7];
int n = 0, i = 0;
clrscr();
scanf("%d", &n);
fflush(stdin);
gets(type_coff);
reg_coff_xy);
reg_coff_yx);
} else
getch();
float sum = 0, i = 0;
sum = sum / n;
return (sum);
void deviation(float *a, float mean, int n, float *d, float *s) {
float sum = 0, t = 0;
int i = 0;
t = d[i] * d[i];
sum = sum + t;
sum = sum / n;
*s = sqrt(sum);
OUTPUT-:
PRACTICAL NO. 7
#include<stdio.h>
float mean_function(float[],int);
float median_function(float[],int);
float mode_function(float[],int);
void main()
float array[SIZE],mean,median,mode;
scanf("%d",&n);
printf("Enter Elements\n");
for(i=0;i<n;i++)
scanf("%f",&array[i]);
do
scanf("%d",&choice);
switch (choice)
case 1:
mean=mean_function(array,n);
printf("\n\t Mean=%f\n",mean);
break;
case 2:
median=median_function(array,n);
printf("\n\t Median=%f\n",median);
break;
case 3:
mode=mode_function(array,n);
printf("\n\t Mode=%f\n",mode);
break;
case 4:
break;
default:
printf("Wrong Option");
break;
while(choice!=4);
int i;
float sum=0;
for(i=0;i<n;i++)
sum=sum+array[i];
return(sum/n);
float temp;
int i,j;
for(i=0;i<n;i++)
for(j=i+1;j<n;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];
{return(3*median_function(a,n)-2*mean_function(a,n));
}
OUTPUT-:
PRACTICAL NO. 8
#include<conio.h>
#include<math.h>
void main()
int n,i;
float avrg,var,SD,sum=0,sum1=0;
int x[MAXSIZE];
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&x[i]) ;
for(i=0;i<n;i++)
sum=sum+x[i] ;
avrg=sum/n;
sum1=sum1+pow((x[i]-avrg),2);
var=sum1/n;
printf("\n\n\nVariance is:.2f",var);
SD=sqrt(var);
printf("\n\n\nS.D is :%2f",SD);
getch();
OUTPUT-: