title: Creating Random Number Using Vectors in C++
body: <p>I'm building a program in which a user types in a number (n) and a set of random numbers is created. So for example, if a user inputs 8, then eight random numbers should be created and  they should range from 0-999,999. The program seems to be compiling, the only problem is, only one random number is being generated. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;cstdlib&gt; 
  
  using namespace std;
  
  main()
  {
      int n;
      int r;
      int i;
      int j;
      vector&lt;int&gt; v;
  
      cout &lt;&lt; "Enter size of vector: ";
      cin &gt;&gt; n;
  
      for (i = 0; i &lt; n; i++)
      {
          v.push_back(n);
          r = rand() % 1000000;
          v[i] = r;
      }
  
      cout &lt;&lt; r &lt;&lt; endl;
  </code></pre>
  
  <p>Can anyone tell me what I'm doing wrong and what I need to do for more than one random number to be generated?</p>