Why does my program keep looping?
<p>I'm trying to sort a 2d array in increasing order and stores them in a one dimensional array (from low to high). </p>

<pre><code>16 22 99 4 18
-258 4 101 5 98
105 6 15 2 45
33 88 72 16 3
</code></pre>

<p>but what i have is keep looping and i don't know why</p>

<pre><code> int main()                  
 {                             
     const int SKIP=-999999;
     const int SIZE=20;
     const int ROWS=4;
     const int COLS=5;         
     int unsorted_array[ROWS][COLS]= {(16,22,99,41,18),
                                      (-258,4,101,5,98),
                                      (105,6,15,2,45),
                                      (33,88,72,16,3)};   
     int s_index=0;
     int min_value,rowMin,rowCol,row,col,colMin;
     int sorted[SIZE];

     cout &lt;&lt;"Array Sorted"&lt;&lt;endl
         &lt;&lt;"___________"&lt;&lt;endl&lt;&lt;endl;


 while (s_index &lt; SIZE)
 {
     rowMin=0;
     rowCol=0;
     min_value = unsorted_array[0][0];
     row=0;
     while (row &lt; ROWS)
     {
         col=0;
         while (col &lt; COLS)
         {
             if (unsorted_array[row][col] &lt; min_value)
             {
                 min_value = unsorted_array[row][col];
                 rowMin = row;
                 colMin = col;
             } 
             ;
             col = col + 1;
         }
         row = row + 1;  
     }
     sorted[s_index] = min_value; 

     while (sorted[s_index] &gt;= 0)
     {
         cout&lt;&lt;" "&lt;&lt;sorted[s_index];
     }
     unsorted_array[rowMin][colMin]=SKIP; 
     s_index=s_index+1; 
}
cout&lt;&lt;endl;
</code></pre>
