Sie sind auf Seite 1von 3

Write an Object Oriented Program fro calculating Median using C++ for

Continuous Series
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float j,s,h1,l[20],u[20],n,f[20],C[20];
float MD=0,N=0;

cout<<"\nEnter the number of observation :";


cin>>n;
cout<<"\nEnter lower limits of the classes :";
for(int i=0;i<n;i++)
{
cin>>l[i] ;
}
cout<<"\nEnter the upper limit of classes :";

for(i=0;i<n;i++)
{
cin>>u[i];
}

cout<<"\nEnter frequencies :";

for(i=0;i<n;i++)
{
cin>>f[i];
}

C[0]=f[0];

for(i=1;i<n;i++)
{
C[i]=f[i]+C[i-1];
}

for(i=0;i<n;i++)
{
N=N+f[i];
}

N=N/2;

cout<<"N="<<N<<"\n";

for(i=1;i<n;i++)
02/11/2021
Created By:- Ashwin Gattani
BCA-I(S1)
Write an Object Oriented Program fro calculating Median using C++ for
Continuous Series
{
if(N<C[i])
{
j=i;
cout<<"j="<<j<<"\n";
s=C[i+1] ;
cout<<"s="<<s<<"\n";
break;

}
}

h1=u[0]-l[0];

MD=l[j]+(float)((h1/f[j])*(N-C[j-1]));

cout<<"Median is: "<<MD;


getch();
}

02/11/2021
Created By:- Ashwin Gattani
BCA-I(S1)
Write an Object Oriented Program fro calculating Median using C++ for
Continuous Series
//OUTPUT//

Enter the number of observation: 8

Enter lower limits of the classes: 0


100
200
300
400
500
600
700

Enter the upper limit of classes: 100


200
300
400
500
600
700
800

Enter frequencies: 5
10
12
16
27
10
15
5

Median is: 425.925934

02/11/2021
Created By:- Ashwin Gattani
BCA-I(S1)

Das könnte Ihnen auch gefallen