0% found this document useful (0 votes)
11 views16 pages

Maths 5th Sem Practical File

The document contains multiple C++ programs that calculate various statistical means, including arithmetic mean for individual and discrete series, harmonic mean for individual and continuous series, and geometric mean for both discrete and continuous series. Each program prompts the user for input, processes the data, and outputs the calculated mean. The programs utilize basic C++ constructs such as loops, arrays, and mathematical functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views16 pages

Maths 5th Sem Practical File

The document contains multiple C++ programs that calculate various statistical means, including arithmetic mean for individual and discrete series, harmonic mean for individual and continuous series, and geometric mean for both discrete and continuous series. Each program prompts the user for input, processes the data, and outputs the calculated mean. The programs utilize basic C++ constructs such as loops, arrays, and mathematical functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Computer Oriented Statistical Method

Q1. Write a program to calculate the Arithmetic mean for individual series by direct
method?
#include<iostream.h>

#include<conio.h>
void main()
{
clrscr();
int n , i , arr[50] , sum=0;
cout<<"how many number you want to enter\n";
cin>>n;
cout<<"enter"<<n<<"number\n";
for(i=0;i<n;i++)
{
cin>>arr[i];
sum=sum+arr[i];
}
int armean=sum/n;
cout<<"arithmetic mean="<<armean;
getch();
}

1 BCA Department Chamba


Computer Oriented Statistical Method
Q2. Write a program to calculate arithmetic mean using frequency distribution for discrete
series?
#include<iostream.h>
#include<conio.h>
void main()
{
int n,i,f[50],sfx=0,sf=0;
float am=0.0;
clrscr();
cout<<"how many number enter in an array"<<endl;
cin>>n;
for(i=0;i<n;i++)
{
cout<<i<<"=";
cin>>f[i];
}
for(i=0;i<n;i++)
{
sf+=f[i];
sfx+=f[i]*i;
}
cout<<"sum of sf="<<sf<<endl;
cout<<"sum of sfx="<<sfx<<endl;
am=sfx/(float)sf;
cout<<"arithmetic mean="<<am;
getch();
}

2 BCA Department Chamba


Computer Oriented Statistical Method

3 BCA Department Chamba


Computer Oriented Statistical Method
Q3. Write a program to calculate the Arithmetic mean for discrete series.
#include<iostream.h>
#include<conio.h>
void main()
{
int n, i,f[50],sfx=0,sf=0;
float am;
clrscr();
cout<<"how many number enter in array"<<endl;
cin>>n;
for(i=0;i<=n;i+=5)
{
cout<<i<<"=";
cin>>f[i];
}
for(i=0;i<=n;i+=5)
{
sf+=f[i];
sfx+=f[i]*i;
}
cout<<"sum of sf="<<sf<<endl;
cout<<"sum of sfx="<<sfx<<endl;
am=sfx/(float)sf;
cout<<"arithmetic mean="<<am;
getch();
}

4 BCA Department Chamba


Computer Oriented Statistical Method

5 BCA Department Chamba


Computer Oriented Statistical Method
Q4. Write a program to calculate arithmetic mean for continuous series.
#include<iostream.h>
#include<conio.h>
void main()
{
int x,y,f[50],sum=0,n=0,m=0;
float am;
clrscr();
for(x=3,y=5;x<=9,y<=11;x+=2,y+=2)
{
cout<<x<<"-"<<y <<" ";
cin>>f[x];
}
for(x=3,y=5;x<=9,y<=11;x+=2,y+=2)
{
n+=f[x];
m=(x+y)/2;
sum+=f[x]*m;
}
cout<<"sum of N="<<n<<endl;
cout<<"sum of sum="<<sum<<endl;
am=sum/(float)n;
cout<<"Arithmetic Mean="<<am;
getch();
}

6 BCA Department Chamba


Computer Oriented Statistical Method
Q5. Write a program to find harmonic mean for individual series.
#include<iostream.h>>
#include<conio.h>
void main()
{
int n,i,x[50];
double sx=0.0;
float hm=0.0 , sum=0.0;
clrscr();
cout<<"how many number want to enter"<<endl;
cin>>n;
for(i=0;i<=n;i++)
{
cout<<i<<" ";
cin>>x[i];
}
for(i=0;i<n;i++)
{
sx=1.0/x[i];
cout<<sx<<endl;
sum+=sx;
}
cout<<"now sum is ="<<sum<<endl;
hm=n/(float)sum;
cout<<"hormonic mean="<<hm;
getch();
}

7 BCA Department Chamba


Computer Oriented Statistical Method

8 BCA Department Chamba


Computer Oriented Statistical Method
Q6. Write a program to calculate the harmonic mean for continuous series.
#include<iostream.h>
#include<conio.h>
void main()
{
int x,y,f[50],sf=0,m=0;
float hm=0.0,sfm=0.0;
clrscr();
cout<<"enter the value of frequency\n";
for(x=2,y=4;x<=8,y<=10;x+=2,y+=2)
{
cout<<x<<"-"<<y<<"";
cin>>f[x];
}
for(x=2,y=4;x<=8,y<=10;x+=2,y+=2)
{
sf+=f[x];
m=(x+y)/2;
sfm=f[x]/(float)m;
}
cout<<"sum of sf="<<sf<<endl;
cout<<" sum of sfm="<<sfm<<endl;
hm=sf/sfm;
cout<<"hamrnonic mean"<<hm;
getch();
}

9 BCA Department Chamba


Computer Oriented Statistical Method

10 BCA Department Chamba


Computer Oriented Statistical Method
Q7. Write a program to calculate geometric mean for individual series.
#include<iostream.h>
#include<conio.h>
void main()
{
int n,i,x[50];
float sum=0.0,gm1=0.0,gm=0.0,sf=0.0;
clrscr();
cout<<"enter the elements of an array"<<endl;
cin>>n;
for(i=0;i<n;i++)
{
cin>>x[i];
}
for(i=0;i<n;i++)
{
sf=log10(x[i]);
cout<<sf<<endl;
sum+=sf;
}
cout<<"now the value of sum="<<sum<<endl;
cout<<"number of elements="<<n;
gm1=sum/n;
gm=pow(10,gm1);
cout<<"the value of gm1="<<gm1<<endl;
cout<<"now the Geometric mean is ="<<gm;
getch();
}

11 BCA Department Chamba


Computer Oriented Statistical Method

12 BCA Department Chamba


Computer Oriented Statistical Method
Q8. Write a program to find Geometric Mean for continuous series.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int x,y,f[50],sf=0,m=0;
float sm=0.0,sfm=0.0,gm1=0.0,gm=0.0;
clrscr();
for(x=0,y=10; x<=40,y<=50;x+=10,y+=10)
{
cout<<x<<"-"<<y<<" ";
cin>>f[x];
}
for(x=0,y=0;x<=40,y<=50;x+=10,y+=10)
{
sf+=f[x];
m=(x+y)/2;
sm=log10(m);
cout<<sm<<endl;
sfm+=f[x]*(float)sm;
}
cout<<"sum of sf="<<sf<<endl;
cout<<"now the value of sfm="<<sfm <<endl;
gm1=sfm/sf;
gm=Pow(10,gm1);
cout<<"value of gm1="<<gm1<<endl;
cout<<"now geometric mean="<<gm<<endl;
getch();

13 BCA Department Chamba


Computer Oriented Statistical Method

14 BCA Department Chamba


Computer Oriented Statistical Method
Q9. Write a program to calculate Geometric Mean for discrete series.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,i,x[50],f[50],sf=0;
float sfx=0.0,sx=0.0,gm1=0.0,gm=0.0;
clrscr();
cout<<"how many number in an array"<<endl;
cin>>n;
cout<<"enter the elements in an array"<<endl;
for(i=0;i<n;i++)
{
cin>>x[i];
}
cout<<"enter elements in an arrayf"<<endl;
for(i=0;i<n;i++)
{
cin>>f[i];
}
for(i=0;i<n;i++)
{
sf+=f[i];
sx=log10(x[i]);
cout<<sx<<endl;
sfx+=f[i]*(float)sx;
}
cout<<"sum of sf="<<sf<<endl;
cout<<"now value of sfx="<<sfx<<endl;
gm1=sfx/sf;

15 BCA Department Chamba


Computer Oriented Statistical Method
gm=pow(10,gm1);
cout<<"value of gm1="<<gm1<<endl;
cout<<"now geometric mean is="<<gm<endl;
getch();
}

16 BCA Department Chamba

You might also like