String max frequency charachter

#include
#include
using namespace std;

int main()
{
char a[1000];
cin >> a;
char b[1000];
int length = 0;
int i;
for ( i = 0; i < strlen(a); i++) // aaaabacd
{ int count = 0;
for (int j = 1; j < strlen(a); j++)
{
if (a[i] == a[j])
{
count++;
}
}
if (length <= count)
{
length = count;
b[i]= a[i];

    }
}
cout << length+1;
 cout<<b[i];
return 0;

}

i have made this code in which t would tell me maximum number of time charchter have occured but why it is not telling that charchter that occured maximum number of time

hi @sahilkumar23102003_bbf6ee38349d98a1 refer here https://ide.codingblocks.com/s/661141, ive commented the code do a dry run yourself once

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.