/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
int len = sizeof(arr) / sizeof(int);
printf("len = %d\n", len);
int temp1 = arr[len - 1];
int temp2 = arr[len - 2];
printf("temp1 = %d\n", temp1);
printf("temp2 = %d\n", temp2);
for(int i = len-1 ; i > 1 ; --i)
{
printf("Moving arr[%d] to arr[%d]\n", i-2, i);
arr[i] = arr[i-2];
}
arr[0] = temp1;
arr[1] = temp2;
for(int i = 0 ; i < len ; ++i)
printf("arr[%d] = %d\n", i, arr[i]);
}