title: How to join 2 arrays into a third one?
body: <p>I want to add <code>a1</code> and <code>a2</code> into a third array, <code>a3</code>. However, it is not working properly.</p>
  <p>When running the following code, the output was:</p>
  <pre class="lang-none prettyprint-override"><code>1 2 3 4 5 5 88237492 23928392 23234242 343344.
  </code></pre>
  <p>Why is that?</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #define MAX_SIZE 30
  int main(){
    int a1[]={1,2,3,4,5};
    int a2[]={1,2,3,4,5};
    int a3[10];
    int i=0;
    int k=0;
    int j=0;
    
    while(i&lt;sizeof(a1)/sizeof(int))
    {
      a3[i]=a1[i];
      i++;
    }
  
    while(j&lt;sizeof(a2)/sizeof(int))
    {
      a3[i]=a2[j];
      j++;
    }
    while(k&lt;sizeof(a3)/sizeof(int))
    {
      printf(&quot;%d &quot;,a3[k]);
      k++;
    }        
  
    return 0;
  }
  </code></pre>