title: C++ How to reverse the order of elements in vector?
body: <p>This is my first ever post on this site as a C++ beginner.
  My question is rather simple.
  Write a function that reverse the order of elements in a vector.
  For example, 1, 3, 5, 7, 9 becomes 9, 7, 5, 3, I. The reverse function
  should produce a new vector with the reversed sequence, leaving its original
  vector unchanged. </p>
  
  <p>And here is my code. When I run it there is nothing coming after the word "Printing". I am pretty sure I made a silly and simple mistake somewhere but just couldn't figure it out. Would appreciate any help.Cheers.</p>
  
  <pre><code>void reverse_a(const vector&lt;int&gt;&amp;v1, vector&lt;int&gt;&amp;v2)
  {
      //this function creates vector2 with the reverse sequence of elements from vector 1
  
  
    for(int i=v1.size()-1;i&lt;=0;--i)
  
    { 
        v2.push_back(v1[i]);
  
    }
  }
  
  void print(const vector&lt;int&gt;&amp;v)
  {
      cout&lt;&lt;"Printing"&lt;&lt;endl;
      for(int i=0;i&lt;v.size();++i)
          cout&lt;&lt;v[i]&lt;&lt;",";
      cout&lt;&lt;"\n"&lt;&lt;"end of print.\n";
  }
  
  int main()
  {
      vector&lt;int&gt;v1;
      vector&lt;int&gt;v2;
      int input;
      while(cin&gt;&gt;input)
          v1.push_back(input);
      reverse_a(v1,v2);
  
      print(v2);
  
      keep_window_open("`");
  
  }
  </code></pre>