title: Bubble Sort Display
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  void bubbleSort(int data[], int n);
  
  int main()
  {
  cout &lt;&lt; "Enter ten unsorted integers..." &lt;&lt; endl;
  
  int a[10];
  for (int i = 0; i &lt; 10; ++  i)
  {
      cout &lt;&lt; "[" &lt;&lt; i &lt;&lt; "] = ";
      cin &gt;&gt; a[i];
  }
  
  cout &lt;&lt; endl &lt;&lt; "Unsorted List = ";
      for (int i = 0; i &lt; 10; ++i)
      cout &lt;&lt; a[i] &lt;&lt; ", ";
  
  cout &lt;&lt; endl;
  
  cout &lt;&lt; "Sorting..." &lt;&lt; endl;
  cout &lt;&lt; "Sorted List = ";
  bubbleSort(a, 10);
  }
  
  void bubbleSort(int data[], int n)
  {
  int j = 0;
  bool nextEnd = true;
  while (nextEnd)
  {
      nextEnd = false;
      ++j;
      for (int i = 0; i &lt; n - j; ++i) 
      {
          if (data[i] &gt; data[i+1]) 
          {
              int temp = data[i];
              data[i] = data[i+1];
              data[i+1] = data[i];
              nextEnd = true;
          }
      }
  }
  
  for (int i = 0; i &lt; 10; ++i)
  cout &lt;&lt; data[i] &lt;&lt; ", ";
  }
  </code></pre>
  
  <p>The program is really simple. Input ten values to an array. Display them unsorted. Send them into the bubbleSort function, sort them and finally display the sorted list. The problem I'm having is I don't get the outputting back to work. I tested with the last line of code but that doesn't work. I don't think my sorting is messed up either. How can I display this sorted list properly?</p>