Why am i getting this kind of output since i know that the default values of non-initialized integer elements of an array is 0?
<pre><code>#include &lt;iostream&gt;

using namespace std;

void RemoveZeroElements(int arr1[],int arr2[],int &amp;i){
    int n=0;
    int m=0;
    while(n&lt;14) {
        switch(arr1[n]) {
            case 0:
                n+=1;
            break;
            default:
                arr2[m]=arr1[n];
                m+=1;
                n+=1;
                i+=1;
             break;

         }
      }
}


int main()
{
    int ar1[14]={2,4,5,0,7,-9,0,0,11,23,44,0,13,999};
    int ar2[14];
    int efsize=0;

    RemoveZeroElements(ar1,ar2,efsize);

    cout&lt;&lt;"the new array without the zeros has an effective size of "&lt;&lt; efsize &lt;&lt; endl;

    for (int i=0;i&lt;14;i++) {

        if(ar2[i]!=0) {
            cout &lt;&lt; "the new array has its " &lt;&lt; (i+1)&lt;&lt; "th element set to " &lt;&lt; 
            ar2[i]&lt;&lt; endl;
        } 
     }

}
</code></pre>

<p>The output i get is the following:</p>

<pre><code>the new array without the zeros has an effective size of 10
the new array has its 1th element set to 2
the new array has its 2th element set to 4
the new array has its 3th element set to 5
the new array has its 4th element set to 7
the new array has its 5th element set to -9
the new array has its 6th element set to 11
the new array has its 7th element set to 23
the new array has its 8th element set to 44
the new array has its 9th element set to 13
the new array has its 10th element set to 999
the new array has its 11th element set to 1
the new array has its 12th element set to 65535
the new array has its 13th element set to 4308980
the new array has its 14th element set to -1079890440
</code></pre>

<p>The problem as you see is in the 12th,13th and 14th elements</p>
