title: Sorting an array from Largest to smallest in C++
body: <p>I wanna sort an array from largest to smallest number and make a new array which has it sorted...</p>
  <p>so here is my code:</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
   int main()
   {
     int size, sum = 0, answer = 0,pos, max;
     int array[size];
    int array2[size];
    cin &gt;&gt; size;
  
     for (int i = 0; i &lt; size; i++)
     {
      cin &gt;&gt; array[i];
      sum+=array[i];
     }
  
     for (int i = 0; i &lt; size; i++)
     {
  
      max = 0;
      pos = 0;
      for (int q = 0; q &lt; size; q++)
      {
        if (array[q] &gt; max)
        {
          max = array[q];
          pos = q;
        }
      }
      array2[i] = max;
      array[pos] = 0;
      
     }
  
     for (int i = 0; i &lt; size; i++)
     {
      cout &lt;&lt; array2[i] &lt;&lt; &quot;, &quot;;
     }
  
   return 0;
   }
  </code></pre>
  <p>When I put my input:</p>
  <pre><code>5
  1 2 3 4 5
  </code></pre>
  <p>The output I get is:</p>
  <pre><code>0, 0, 0, 0, 5,
  </code></pre>
  <p>but I expect it to be 5, 4, 3, 2, 1,</p>