Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  frequency
Language: C/C++
Code:
#include<iostream.h>
#include<conio.h>
class frequency
{
private:int i,n,a[100],ele,count;
public:void input();
       void compute();
       void output();
};
void frequency::input()
{
cout<<"how many elements"<<endl;
cin>>n;
cout<<"enter the array elements"<<endl;
for(i=0;i<n;i++)
cin>>a[i];
cout<<"enter the element to be searched"<<endl;
cin>>ele;
}
void frequency::compute()
{
count=0;
for( i=0;i<n;i++)
if(a[i]==ele)
count++;
}
void frequency::output()
{
if(count>0)
cout<<ele<<"occurs"<<count<<"times"<<endl;
else 
cout<<ele<<"does not occur"<<endl;
}
void main()
{
frequency f;
clrscr();
f.input();
f.compute();
f.output();
getch();
}

          
          
          
Comments: