title: Selection sort program not sorting correctly
body: <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      int n, arr[10], i, j, temp, minin;
      cin &gt;&gt; n;
      for (i = 0; i &lt; n; i++)
      {
          cin &gt;&gt; arr[i];
      }
      for (i = 0; i &lt; n - 1; i++)
      {
          minin = i;
          for (j = i + 1; j &lt; n; j++)
          {
              if (arr[j] &lt; arr[minin])
                  minin = j;
              temp = arr[minin];
              arr[minin] = arr[i];
              arr[i] = temp;
          }
      }
      for (i = 0; i &lt; n; i++)
      {
          cout &lt;&lt; arr[i];
      }
      return 0;
  }
  </code></pre>
  <p>There are no compile-time errors. But my code does not sort properly.</p>
  <p>This is what I get:</p>
  <p><strong>INPUT :</strong></p>
  <pre><code>4 //size of the array to be sorted
  5 3 2 8 //actual array to be sorted
  </code></pre>
  <p><strong>OUTPUT :</strong></p>
  <pre><code>3528
  </code></pre>
  <p>The expected output is the sorted array in ascending order.</p>