Write a fuction called delete_repeats that has a partiallyfilled array of charac
ID: 3619067 • Letter: W
Question
Write a fuction called delete_repeats that has a partiallyfilled array of characters as a formal parameter and that deletesall repeated letters from the array. Since a partially filled arrayrequires two argrments, the function will actually hace two formalparameters: an array parameter of type int thaat gives thenumber of array positions used. When a letter is deleted, theremaining letters are moved forward to fill in the gapl This willcreate empty positions at the end of the array so that less of theformal parameter of type int will tell how may array positions arefilled. This second formal parameter will be a call by referenceparameter and will be chaged to show how much of the array is usedagter the repeated letters are deleted. For example, consider thefollowing code. char a[10]; a[0] = 'a'; a[1] = 'b'; a[2] = 'c'; a[3] = 'b'; int size = 4; delete_repeats(a, size); After this code is executed the value of a[0] is 'a', thevalue of a[1] is 'b', the value of a[2] is 'c', and the value ofsize is 3. (The value of a[3] is no longer of any concern, sincethe partially filled array no longer uses this indexedvariable.) You may assume that the partially filled array contains onlylowercase letters. Embed your function in a suitable testprogram. Write a fuction called delete_repeats that has a partiallyfilled array of characters as a formal parameter and that deletesall repeated letters from the array. Since a partially filled arrayrequires two argrments, the function will actually hace two formalparameters: an array parameter of type int thaat gives thenumber of array positions used. When a letter is deleted, theremaining letters are moved forward to fill in the gapl This willcreate empty positions at the end of the array so that less of theformal parameter of type int will tell how may array positions arefilled. This second formal parameter will be a call by referenceparameter and will be chaged to show how much of the array is usedagter the repeated letters are deleted. For example, consider thefollowing code. char a[10]; a[0] = 'a'; a[1] = 'b'; a[2] = 'c'; a[3] = 'b'; int size = 4; delete_repeats(a, size); After this code is executed the value of a[0] is 'a', thevalue of a[1] is 'b', the value of a[2] is 'c', and the value ofsize is 3. (The value of a[3] is no longer of any concern, sincethe partially filled array no longer uses this indexedvariable.) You may assume that the partially filled array contains onlylowercase letters. Embed your function in a suitable testprogram.Explanation / Answer
please rate - thanks in response to your message #include using namespace std; void deletes(char[],int&); int main() {int i,size; char a[20]; deletes(a,size); cout a[index]; } for(int index = 0; indexRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.