title: How to implement shifting of sub-array one position
body: <p>How can we shift array members one position?</p>
  
  <p>For example, if we have <strong>n</strong> sized array with one <strong>empty</strong> element, and we shift all elements to right of a member <strong>pos</strong> by one position, we can copy <strong>n-1</strong>th member into the empty element, and so on. </p>
  
  <p>code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  // we take the position of insertion, then right shift all elements
  // then insert the required number
  
  int main() {
      int n = 10;
      int list[n];
  
      cout &lt;&lt; "Enter " &lt;&lt; n-1  &lt;&lt; " elements:\n";
  
      for( int i = 0; i &lt; n-1; ++i) {
          cin &gt;&gt; list[i];
      }
  
      int pos, num;
  
      cout &lt;&lt; "Position ( start: 1 ): ";
      cin &gt;&gt; pos;
  
      if( pos &lt; n &amp;&amp; pos &gt;= 0 ) {
          cout &lt;&lt; "No. to be inserted: ";
          cin &gt;&gt; num;
  
          for( int i = n-2; i &gt;= pos-1; --i) {
              list[i+1] = list[i];
          }
          list[pos-1] = num;
  
          for( int i = 0; i &lt; n; ++i) {
              cout &lt;&lt; list[i] &lt;&lt; ' ';
          }
  
          return 0;
      }
  }
  </code></pre>
  
  <ul>
  <li><p>But can we not, by some means, s<strong>hift the whole sub-array in one go,</strong> sliding all members right by one?</p></li>
  <li><p>Also can we implement this with <strong>vectors</strong>? And will vectors be more efficient or <strong>better</strong> way to achieve this?</p></li>
  </ul>