I'm causing input letters to write ones into variables through an array. I'm trying to count the occurences of ones in a variable. Lets say I input aaaaa. The count output displays 12345. Instead of outputting the whole count of numbers, I want to output the biggest number in the count. How can I do that?

Look for the biggest number.

Here is hint for finding largest number in count.

Extract digits from count and insert them in an array.

Finding largest element in an array.

 max = array[0] ;

 i = 1;

 while ( i <= array length )
 {
    if( array[i] > max )
    {
       max = array[i] ;
    }

 }

How to extract digits from count ?

First do count modulo 10 and take remainder. It gives the last digit.
Then divide count by 10 and store it in an integer so that, the last digit is left out ( This happens because dividing integer by 10 gives a float value with decimal point before last digit ).
Continue the process untill dividing by 10 gives answer 0.

Hope this helps.

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.