An important part of programming is seeing similarities between different lines of code, and being able to "factor out" that functionality, like multiplication:
3 * x + 3 * y + 3 * z + 3 * w = 3 * (x + y + z + w)
To me, the pattern is, myarray[i] = myarray[i+1]
Now, what is i, though? i ranges from 0 to 3, right?
That's where the for loop comes in,
1 2 3 4 5 6 7
int n = 5;
int temp = myarray[0];
for (int i = 0; i < n-1; i++) // i will be in range[0, 4] inclusive
{
myarray[i] = myarray[i+1];
}
myarray[n-1] = temp;