title: C++ unable to find multiple modes
body: <p>My assignment asks me to write a function that takes an array and the size of that array as a parameter, and to find the mode.  If there are multiple modes, I am to find them all, and place them in a vector and print said vector in an ascending order.</p>
  
  <p>For example, if I input the following integers: </p>
  
  <pre><code>3, 4, 2, 1, 2, 3
  </code></pre>
  
  <p>Then the output should display</p>
  
  <pre><code>2, 3
  </code></pre>
  
  <p>If I input the following integers: </p>
  
  <pre><code>1, 2, 3, 4
  </code></pre>
  
  <p>Then the output should display:</p>
  
  <pre><code>1, 2, 3, 4.
  </code></pre>
  
  <p>However, my program somehow only finds the first mode and displays it in a really awkward manner.</p>
  
  <p>Here was my input: </p>
  
  <pre><code>3, 4, 2, 3, 2, 1
  </code></pre>
  
  <p>And this was the output: </p>
  
  <pre><code>3
  3
  3
  3
  3
  </code></pre>
  
  <p>Here is my code.  Any help would be greatly appreciated.  Thank you all for your time!</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;algorithm&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  int main() {
     int size;                              //array size
     int* array;                            //array of ints
     int arraycount;                        //counter for array loop
     void findMode(int array[], int size);  //function prototype
  
  //intialize array
     cout &lt;&lt; "Enter number of integers ";
     cout &lt;&lt; "you wish to input." &lt;&lt; endl;
     cin &gt;&gt; size;
  
     cout &lt;&lt; "Enter the integers." &lt;&lt; endl;
  
     array = new int[size];
  
     for (arraycount = 0; arraycount &lt; size;
     arraycount++)
        cin &gt;&gt; array[arraycount];
  
  //call function
     findMode(array, size);
  
     return 0;
  }
  
  void findMode(int array[], int size) {
     int counter = 1;
     int max = 0;
     int mode = array[0];
     int count;
     vector &lt;int&gt; results;
  //find modes
     for(int pass = 0; pass &lt; size - 1; pass++) {
        if(array[pass] == array[pass+1]) {
           counter++;
           if(counter &gt; max) {
              max = counter;
              mode = array[pass];
           }
        }
        else {
           counter = 1;
        }
     }
  
  //push results to vector
     for (count=0; count &lt; size - 1; count++) {
        if(counter == max) {
        std::cin &gt;&gt; mode;
        results.push_back(mode);
        }
     }
  
  //sort vector and print
     std::sort(results.begin(), results.end());
     for (count=0; count &lt; size - 1; count++) {
           cout &lt;&lt; mode &lt;&lt; endl;
     }
  }
  </code></pre>