title: Right shift elements in an array by n
body: <p>I want to shift elements in one array to right by <strong>only changing the index</strong>. Also <strong>I don't want to use built-in functions</strong></p>
  
  <p>For example, if we have</p>
  
  <blockquote>
    <p>8,6,5,3,9</p>
  </blockquote>
  
  <p>Then We will have</p>
  
  <blockquote>
    <p>9,8,6,5,3</p>
  </blockquote>
  
  <p>If the array doesn't have enough length. the rest of the elements shift will start from the first index of array.</p>
  
  <pre><code>   int index = 0, temp = 0;
          int[] myarray = new int[int.Parse(Console.ReadLine())];
          for (int i = 0; i &lt; myarray.Length; i++)
          {
              myarray[i] = int.Parse(Console.ReadLine());
          }
  
          for (int i = 0; i &lt; myarray.Length; i++)
          {
              if (myarray.Length &lt;= i + 5)
              {
                  index = ((i + 5) % 5);
                  temp = myarray[index];
                  myarray[index] = myarray[i];
                  myarray[i] = temp;
              }
              else
              {
                  temp = myarray[i + 5];
                  myarray[i + 5] = myarray[i];
                  myarray[i] = temp;
              }
          }
  </code></pre>
  
  <p>this is what i have tried but its not working</p>