1 // Shift array elements to right
2 const int SIZE = 9;
3 int arr[SIZE]={1,2,3,4,5,6,7,8,9};
4
5 int last = arr[SIZE - 1];
6 for (int i = SIZE - 1; i > 0; i--)
7 arr[i] = arr[i - 1];
8
9 arr[0] = last;
1 int temp=arr[0];
2 /******************************** Method 1
3 for (int i = 0; i < SIZE - 1; i++)
4 {
5 arr[i] = arr[i + 1];
6 }
7 arr[SIZE-1]=temp;
8 */
9 // Method 2
10 for (int i = 1; i < SIZE - 1; i++)
11 {
12 arr[i - 1] = arr[i];
13 }
14 arr[SIZE - 1] = temp;
15 for (int i = 0; i < SIZE; i++)
16 cout << arr[i] << "\t";
17 cout << endl;
18