title: loop values are not updated outside of the loop in C++
body: <p>I have a problem here. When I try to access <code>t1[val]</code> outside the loop, I get a garbage value.</p>
  
  <pre><code>int P[ ]={3,7,6,5,2,4,1,8};
  int N[ ]={8,6,7,2,5,3,4,1}; 
  int r= (sizeof(P)/sizeof(*P));
  int s= (sizeof(N)/sizeof(*N));
  int val=r/2 ;
  int t1[val],t2[val],t3[val],t4[val],n=0,p=0;
  
  for(int m=0;m&lt; val;m++){
    t1[n]=P[m];
    t2[n]=N[m];
    n++;
  }
  
  cout &lt;&lt; t1[val];
  </code></pre>