Im trying to make a program that shifts all my elements of array to the right by one and move the last element
into the first position.how would i move the last number out then shift numbers over then move the last number back
into the fist position? here is my code
#include <stdio.h>
int main ()
{
int array[6];
int x;
int temp;
printf("Enter six numbers.\n\n");
// ---------- gets numbers from user -------------------
for(x = 0; x < 6; x++) {
printf ("Enter a number : ", x+1);
scanf ("%d",&array[x]);
}
// ----------------- move the last guy out -------------------
//this is what i need help with
// ----------------- shift everybody over ---------------------
for(x = 6; x > 0; x--)
{
array[x]=array[x-1];
}
// ------------------ put the last guy back into the first one ------
// -------------------- print the array contents -------------------
for(x = 0; x < 6; x++)
{
printf("%d\n", array[x]);
}
return 0;
}