title: Returning static/ normal arrays in recursion/another function
body: <p>A non-static array is declared in one function, it is returned and stored in another non-static array in main.</p>
  
  <p>Q 1> I know that when an array is passed, it is passed by pointer(not by reference) so any changes made to the array in the passed function gets reflected in the original function but in this case while returning that array to another function say main shouldn't the original array be destroyed when it goes out of it's function scope?</p>
  
  <blockquote>
    <p>Static variable retain value within function calls and it's lifetime is the entire program so it is justified for a static array but why so for a non static array?</p>
  </blockquote>
  
  <p>Q 2>Now say we have a non-static array declared inside a function that undergoes recursion, does the array gets declared each time it recurses? It doesn't goes out of the scope so the array is re-declared so why doesn't it gives a redeclaration error? Is it a new array or does the array gets over-written?</p>
  
  <p>Say we have a static array now, it being a static it is declared only once..</p>
  
  <blockquote>
    <p>Does changes made in the array in one recursion gets reflected in another recursion if the array is static/non static?</p>
  </blockquote>
  
  <p>I tried it out and I got that for non static arrays changes are not reflected but in static arrays the changes are reflected so again it basically boils down to the first question?</p>
  
  <p>Q 3> Say we declared a static array and we run two tests(one imp thing to mention is we need the values we get in the previous recursion for the next recursion), the arrays values stored in the first test case(it being static) leads to incorrect values stored during the second test case run(well consider it as a vector so it will give incorrect output when we push the elements in second run since the values stored in the first run are already in the vector). Can you suggest a way to get around this w/o removing the static array</p>
  
  <blockquote>
    <blockquote>
      <p>I know I have asked many questions all together at the same time, but I did that because they are all related 1 and 2 more so. 3 will help me clear my doubts better. It will be very helpful if you can clear the doubts. Thank You</p>
    </blockquote>
  </blockquote>