I did it somehow. But the problem now is that the last k numbers are replaced with the first k variables whose original values have been replaced...

Code:

#include <iostream>
using namespace std;
void shiftArray(int numbers[], int sizeofArray, int k)
{
int index;
for(index = 0; index < sizeofArray; index++)
{
if(index >= sizeofArray - k)
{
numbers[index] = numbers[index % (sizeofArray - index)];
}
else
{
numbers[index] = numbers[index + k];
}
}
}
int main(int argc,char* argv)
{
int numbers[] = {1, 2, 3, 4, 5, 6, 7, 8};
int k = 3;
int sizeofArray = 8;
shiftArray(numbers, sizeofArray, k);
int i;
for(i = 0; i < sizeofArray; i++)
{
cout << numbers[i] << " ";
}
cout << endl;
return 0;
}

Also, isn't it another way to determine the size of an array on the fly so I do not use a storage variable?