Step-by-step explanation:
The below code has been written in C language
void rotateright(int list[], int n)
{
int x = list[n-1]
int i;
for (i = n-1; i > 0; i--)
list[i] = list[i-1];
list[0] = x;
}
void rotateleft(int list[], int n)
{
int x = list[0]
int i;
for (i = 1; i < n-1 ; i++)
list[i] = list[i+1];
list[n-1] = x;
}
int main()
{
int list[] = {x1, x2, x3, ... x(n-1),xn}
int i;
int n = sizeof(list);
rotateright(list, n);
rotateleft(list, n);
return 0;
}