title: How to dynamically input array in c++?
body: <p>This is a simple code where I want to print the elements of an array which are provided as input.</p>
  
  <pre><code>int main() {
      int t;
      cin&gt;&gt;t;
      while(t--){
          int n;
          cin&gt;&gt;n;
  
          int *arr = new int[n];
          for(int i=0;i&lt;n;i++)
              cin&gt;&gt;arr[i];
  
          for(int i=0;i&lt;n;i++)
              cout&lt;&lt;arr[i];
          cout&lt;&lt;endl;
      }
      //code
      return 0;
  }
  </code></pre>
  
  <p><strong>input:</strong></p>
  
  <pre><code>2
  5
  1 2 3 5
  10
  1 2 3 4 5 6 7 8 10
  </code></pre>
  
  <p><strong>ouput poduced by this code</strong></p>
  
  <pre><code>123510
  2
  </code></pre>
  
  <p>but this shouldn't be the output as it should produce the other array from 1-10.</p>
  
  <p>There must be a silly  mistake but i don't know where</p>