title: Shifting an array to the right
body: <p>I'm generating an array of random integers and trying to shift the values one to the right and replace the first element with the former last element. </p>
  
  <p>The output is not ordered, and the final element is a randomly generated integer.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  
     void shift(int values[], int size) {
      int temp;
      for (int i = 0; i &lt; size; i++) {    
          temp = values[size - 1];
          values[i] = values[i + 1];
          values[0] = temp;
          cout &lt;&lt; values[i] &lt;&lt; setw(4);
      }
      cout &lt;&lt; endl;
  }
  int main()
  {
      cout &lt;&lt; "Random 10 index array" &lt;&lt; endl;
      const int CAP = 10;
      int numbers[CAP];
  
      srand(time(0));
      int i;
      for (i = 0; i &lt; CAP; i++) {
          int rng = rand() % 100 + 1;
          numbers[i] = rng;
          cout &lt;&lt; numbers[i] &lt;&lt; setw(4);
  
      }
      cout &lt;&lt; "shifting all elements to the right: " &lt;&lt; endl;
  shift(numbers, CAP);
  
      cout &lt;&lt; endl;
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>I tried using <code>i &lt; size - 1</code>, but I got 9 out of the 10 numbers I needed.</p>