title: Adding Two Arrays Yields Unstable Return
body: <p>I have created a script to add two arrays which is presented below. When the code below is executed it does not produce consistent results. Every time the script is executed I receive different answers. I am curious to determine what could be the cause of such a result.</p>
  <pre><code>//
  //  main.c
  
  #include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  
  int *AddArrays(int *A, int *B, int a, int b);
  
  int main(void)
  
  {
      int A[5] = {1,2,3,4,5};
      int B[7] = {6,7,8,9,10,11,12};
      int a = 5;
      int b = 7;
      int c = a + b;
      int x = 0;
      int NewArray[c], *ArrayPtr;
      
      ArrayPtr = AddArrays(A,B,a,b);
  
      for( x = 0; x &lt; c; x++)
      {
          *(NewArray + x) = *ArrayPtr;
          
          printf(&quot;Value of NewArray[%d] = %d\n&quot;, x, *(NewArray+x));
          sleep(1);
          
          ArrayPtr++;
      }
      
      
      return 0;
  }
  
  int *AddArrays(int *A, int *B, int a, int b)
  {
      int c;
      int d;
      int NewArray[a+b];
      
      for (c = 0; c &lt; a; c++)
      {
          NewArray[c] = *A;
          A++;
          
      }
      
      for (d = 0; c &lt; d; d++)
      {
          NewArray[a] = *B;
          a++;
          B++;
      }
      
      return NewArray;
  }
  </code></pre>