You are on page 1of 2

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

Discrete Series

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,f[20],mode=0,x[20],a;

cout<<"Enter the number of observations:-";


cin>>n;

cout<<"\n Enter the Observations:-\n";

for(i=1;i<=n;i++)
{
cin>>x[i];
}

cout<<"\n Enter the Frequencies:-\n";

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

for(i=1;i<=n;i++)
{
if(mode<f[i])
{
mode=f[i];
a=i;
}
}

cout<<"mode="<<x[a];

getch();
}

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

//OUTPUT//

Enter the Observations:


10
12
14
16
18
19
20
22
24
26

Enter the Frequencies:


2
7
9
13
28
10
8
6
3
2

Mode is: 18

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

You might also like