Sie sind auf Seite 1von 6

PROBABILITY AND STATISTICS

NAME:

NEHA MALIK

CLASS :

BCSM-3G

ROLL NO:

BCSM-F18-116

SUBMITTED TO:

MAM SIDRA

SEPTEMBER 23, 2019

NEHA
Problem 1 – Write a program to calculate the arithmetic mean (i.e., average), geometric mean and harmonic mean of a
set of n numbers x1,x2,……..,xn are defined as follows:

Since computing geometric mean requires taking square root, it is further required that all input
data values must be positive. As a result, this program must be able to ignore those non-positive
items. However, this may cause all input items ignored. Therefore, before computing the means,
this program should have one more check to see if there are valid items.

C++ PROGRAM :
#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;

void arithmeticmean()
{
double x ,sum=0,remain;
int n;
cout<<"enter the mean "<<endl;
cin>>n;
for(int i=1;i<=n;i++)
{
cout<<"enter the value "<<endl;
cin>>x;
sum=sum+x;
}
remain=sum/n;
cout<<"the arithmetic mean of this is "<<remain<<endl;;

}
void geometricmean()
{
double x ,multiply=1,remain,n;
cout<<"please enter the geometric mean"<<endl;
cin>>n;
for(int i=1;i<=n;i++)
{
cout<<"ENTER THE VALUE"<<endl;
cin>>x;
multiply=multiply*x;
}
remain=pow(multiply,1/n);
cout<<" the result iss"<<endl;
cout<<remain<<endl;

}
void harmonicmean()
{
double x ,inverse=0,remain;
int n;
cout<<"enter the mean "<<endl;
cin>>n;
for(int i=1;i<=n;i++)
{
cout<<"enter the value "<<endl;
cin>>x;
inverse=inverse+1/x;
}
remain=n/inverse;
cout<<"the harmonic mean of this is "<<remain<<endl;;

}
int main()
{
int option;
int op;
while(op!=4)
{
cout<<"press 1 for arithmetic mean"<<endl;
cout<<"press 2 for geometric mean"<<endl;
cout<<"press 3 for harmonic mean "<<endl;
cin>>option;
switch(option)
{
case 1:
arithmeticmean();
break;
case 2:
geometricmean();
break;
case 3:
harmonicmean();
break;
case 4:
op==4;
break;
default:
cout<<"invalid option"<<endl;
}
}
return 0;

Problem 2 – Create a bar chart, histogram and frequency polygon for the average income of a sample
of people in their thirties by age based on the data given below.

Age 31 32 33 34 35 36 37 38 39 40
(years)
Income 23500 24000 25000 26700 27500 29200 33000 35100 37400 39500
(Rupees)
BAR CHART:

FREQUENCY POLYGON:
HISTOGRAM:

Problem 3 – The table below shows the quantity in hundred kgs of wheat, barley and
oats produced in a certain form during the years 1991 to 1994.

MULTIPLE BARCHART:
PIE CHART:

wheat

21%
30% 1991
1992
1993
26%
23% 1994

barley

1991 1992 1993 1994

Thank you…

Das könnte Ihnen auch gefallen