title: How to get each iteration in a for loop into a list/vector? (C++)
body: <p>I am attempting to take a value N, and create a list/vector with all of the values from N to 0 (not inclusive), and then N again. </p>
  
  <p>After defining N, I have the following code:</p>
  
  <pre><code>for (int i = N; i &gt; 0; i--) {
      cout &lt;&lt; i &lt;&lt; endl;
  }
  </code></pre>
  
  <p>This neatly prints out the required values. For example, with N=3:</p>
  
  <pre><code>3
  2
  1
  3
  </code></pre>
  
  <p>The issue is that I can't manipulate these to compute what I want to (namely the mean, range, maximum and minimum values). So what I need to do is to get each iteration to put itself into an array, the same array that the previous iteration put itself in.</p>
  
  <p>I have found a similar question on here (<a href="https://stackoverflow.com/questions/19801995/how-to-store-the-result-of-each-iteration-of-a-for-loop-into-an-array-javascrip">How to store the result of each iteration of a for loop into an array (Javascript)</a>), except it's in javascript, which is causing some issues for me.  </p>
  
  <p>Why does the following not work on C++, and how can I change it?</p>
  
  <pre><code>var array = []
  for (int i = N-1; i &lt; N; i--) {
      array.push(i);
  }
  </code></pre>
  
  <p>The same thing with int replacint var does not work either. </p>
  
  <p>Any suggestions?</p>