moveToBeginning: Put the value that was elimiated into the first position of the array

All About Code
2 min readMay 4, 2022

int moveToBeginning(string a[], int n, int pos);

Eliminate the value at position pos by copying all elements before it one place to the right. Put the value that was thus eliminated into the first position of the array. Return the original position of the item that was moved to the beginning. Here's an example:

string people[5] = { "juliet", "sierra", "samuel", "echo", "november" };
int s = moveToBeginning(people, 5, 2); // returns 2
// people now…