Posted by: alece September 25, 2015
C++
Login in to Rate this Post:     0       ?        
sigh!! kati desperate bhako bro..tait..and start using stackoverflow jeez.
I hope now you can figure out on how to do with file input...

string mostFrequent(string input)
{
int max = 0;
int count = 0;
string mostOccuringChar;
for(char a=' ';a<='~';a++)

{
count = 0;
for(int i=0; i) {
if(input[i]==a)
count++;
}

if(count == max)
{
mostOccuringChar += a;
}

if(count>max)
{
max=count;
mostOccuringChar=a;
}
}

return mostOccuringChar;
}
int main()
{
cout <<"The letter that occurs most is: "<< mostFrequent("Hello World") < system("pause");
}


Last edited: 25-Sep-15 08:58 AM
Read Full Discussion Thread for this article