will find number which is used frequently(often) in x array

int i;
int x[i],frequency[i];

for(int i=0;i<3;i++)
{
cin>>x[i];
frequency[i]=0;
}

frequency[i]=0;

for(int i=0;i<3;i++)
{
frequency[i]++;
cout<<x[i];
} 
frequency[i]++;
cout<<x[i];
cout<<frequency[i];

what should I do extra

Recommended Answers

All 3 Replies

Scoping problems. Too many variables named i. Make sure i is what you think it is.

Line 2 - wrong. The numbers in the brackets is the size. It's not a variable, particularly not an uninitialized variable. I assume it should be 3 instead of i?

Line 10. Scoping problems. i is used uninitialiazed.

Same with lines 17 through 19.

What precisely are you trying to do?

there are array of numbers for example:
I typed: 3
I typed: 3
I typed: 5

and

frequently number is: 3

I want to write the code which will do this

there are array of numbers for example:
I typed: 3
I typed: 3
I typed: 5

and

frequently number is: 3

I want to write the code which will do this

You want to find the mode?

http://en.wikipedia.org/wiki/Mode_(statistics)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.