title: C++ Bubble Sorting and Selection Sorting
body: <p>Here's the problem.</p>
  
  <p>Write a program that uses two identical arrays of at least 20 integers. It should call a function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should keep a count of the number of exchanges it makes. The program then should call a function that uses the selection sort algorithm to sort the other array. It should also keep count of the number of exchanges it makes. Display these values on the screen.
  Here's where my problem is. I can do void <code>bubbleSort</code> and void <code>selectionSort</code> and sort 20 random numbers that I input but I'm having a hard time trying to figure out how to add a counter for the number of exchanges in each of the sorting methods. </p>
  
  <p>Also, the instruction says to use <code>int bubbleSort(long [], int);</code> and <code>int selectionSort(long [], int);</code>. I'm confused why I would be using int instead of void. Perhaps I use both?</p>
  
  <p>Anyways, any help is greatly appreciated. Thank you.</p>
  
  <p>edit: Here's what I have so far. </p>
  
  <pre><code>//Sorting Benchmarks
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  // Function Prototypes
  void sortArray (int [], int);
  void showArray (const int [], int);
  int bubbleSort(long [], int);
  int selectionSort(long [], int);
  
  int main()
  {
      // Define an array with unsorted value
      const int SIZE = 20;
      int values[SIZE]{20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1);
  
      // Display the values
      cout &lt;&lt; "The unsorted values are:\n";
      showArray(values, SIZE);
  
      //Sort the values. 
      sortArray(values, SIZE);
  
      //Display them again.
      cout &lt;&lt; "The sorted values are:\n";
      showArray(values, SIZE);
  
      return 0;
  }
  
  void sortArray(int array[], int size)
  {
       bool swap;
       int temp;
  
       do
       {
           swap = false;
           for (int count = 0; count &lt; (size - 1); count++)
           {
               if (array[count] &gt; array[count + 1])
               {
                                temp = array[count];
                                array[count] = array[count + 1];
                                array[count + 1] = temp;
                                swap = true;
                                count++
                                dispCount()
                                }
                                }
                                } while (swap);
                                }
  
  void dispCount()
  {
       cout &lt;&lt; "The current number of exchanges are " &lt;&lt; count &lt;&lt; endl;
  }
  
  void showArray(const int array[], int size)
  {
       for (int count = 0; count &lt; size; count++)
           cout &lt;&lt; array[count] &lt;&lt; " ";
           cout &lt;&lt; endl;
  
           system("PAUSE");
           }
  </code></pre>
  
  <p>With this, I'm getting a million errors, the biggest one being in int main, where it says expected primary-expression before "int" and expected ';' before "int". I've checked and I feel all the ;'s are where they belong. </p>