title: how to get correct answer merge 2 sorted arrays?! C++
body: <p>i wrote a little algorithm for marge to sorted array. but i have problem with that.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
  
      // main function started form here:
  
      int firstArray[10] = {1,3,5,7,9,11,13,15,17,19};
      int secondtArray[10] = {2,4,6,8,10,12,14,16,18,20};
  
      int mergedArray[20];
      int firstCounter=0 , secondtCounter=0 , mergedCounter=0;
  
      while(firstCounter &lt; 10 &amp;&amp; secondtCounter &lt; 10){
          if(firstArray[firstCounter] &lt; secondtArray[secondtCounter]){
              mergedArray[mergedCounter] = firstArray[firstCounter];
              firstCounter++;
          } else {
              mergedArray[mergedCounter] = secondtArray[secondtCounter];
              secondtCounter++;
          }
          mergedCounter++;
      }
  
      while(firstCounter &lt; 10) {
          mergedArray[mergedCounter] = firstArray[firstCounter];
          firstCounter++;
          mergedCounter++;
      }
  
      while(secondtCounter &lt; 10) {
          mergedArray[mergedCounter];
          secondtCounter++;
          mergedCounter++;
      }
  
      for(int j=0; j&lt;20; j++){
          //cout &lt;&lt; mergedArray[j] &lt;&lt; endl;
      }
      cout &lt;&lt; mergedArray[19];
  
      return 0;
  }
  </code></pre>
  
  <p>in outpout for array <code>mergedArray[19]</code> i get something like this: <code>2686916</code>!!!</p>
  
  <p>i don't know why i get this value. how can i fix that. and why i get this value.</p>