title: How do I find the length of the longest run in my array?
body: <p>I'm trying to write a program to return an integer value of the length of the longest run of repeated numbers. (e.g., an array of integers such as, 2, 4, 4, 1, 3, 4, 4, 4, 4, 4, 6, 6, 6 would return the value 5 since the 5 4's is the longest run.) I've tried writing the code, but it keeps returning the total number of elements in my array. What's going wrong?</p>
  
  <pre><code>int length(int array[], int size)
  {
     int x = 0, max;
     int result[size];
  
     for (int i = 0; i &lt; size; i++)
     {
        x = i + 1;
  
        if (array[i] == array[x])
        {
           result[i] = x + 1;
        }
  
        if (result[i] &gt; result[x])
        {
           max = result[i];
        }
     }
  
     return max;
  }
  </code></pre>