The following letters are stored in an alphabet array: B, J, K, M, S, and Z.
Write and test a function named adlet(), which accepts the alphabet array and a new letter
as arguments, and then inserts the new letter in the correct alphabetical order in the array.
void sortNewArray(char array[], char newLetter)
{
for (int i = 0; i < newLetter - 1; i++)
{
if (array[i] > array[i + 1])
{
int temp = array[i + 1];
array[i + 1] = array[i];
array[i] = temp;
i = -1;
}
}
}
void adlet(char array[], char newLetter)
{
char newLetter;
char newArray[7];
newArray[7] = array[6] + newLetter;
sortNewArray(newArray,newLetter);
}
int main()
{
char newLetter;
cout << " Enter a new letter" << endl;
cin >> newLetter;
char array[] = "BJKMSZ";
adlet(array,newLetter);
char a;
cin >> a;
}