here is code
#include <iostream>
#include <map>
using namespace std;
int main(){
map<int ,int>a;
map<int,int>::iterator it;
int b[]={2,4,3,5,2,6,6,3,6,4};
for (int i=0;i<(sizeof(b)/sizeof(b[0]));i++){
++a[b[i]];
}
// for (it=a.begin();it!=a.end();it++){
// cout<<(*it).first<<" =>"<<(*it).second<<"\n";
//}
int max=a.begin()->second;
for (it=a.begin();it!=a.end();it++){
if ((*it).second>max){
max=(*it).second;
}
}
for (it!=a.begin();it!=a.end();it++){
if ((*it).second==max){
cout<<(*it).first<<"\n";
}
}
return 0;
}
what i am trying is following according to number of occurence of each keys i want it print element which occurs most often in this case 6 but it does not show me result what is mistake?