Question: Write a function called deleteRepeats that has a partially filled array of characters as a formal parameter and that deletes all repeated letters from the

Write a function called deleteRepeats that has a partially filled array of characters as a formal parameter and that deletes all repeated letters from the array. Since a partially filled array requires two arguments, the function will actually have two formal parameters: an array parameter and a formal parameter of type int that gives the number of array positions used. When a letter is deleted, the remaining letters are moved forward to fill in the gap. This will create empty positions at the end of the array so that less of the array is used. Since the formal parameter is a partially filled array, a second formal parameter of type int will tell how many array positions are filled. This second formal parameter will be a call-by-reference parameter and will be changed to show how much of the array is used after the repeated letters are deleted.

For example, consider the following code:

char a[10]; a[0] = 'a'; a[1] = 'b'; a[2] = 'a'; a[3] = 'c'; int size = 4; deleteRepeats(a, size);

After this code is executed, the value of a[0] is 'a', the value of a[1] is 'b', the value of a[2] is 'c', and the value of size is 3. (The value of a[3] is no longer of any concern, since the partially filled array no longer uses this indexed variable.)

You may assume that the partially filled array contains only lowercase letters. Embed your function in a suitable test program.Write a function called deleteRepeats that has a partially filled array of

characters as a formal parameter and that deletes all repeated letters from

MAKE SURE YOU USE:

#include

//modifies array to delete all instances of any duplicates //of characters found in array void deleteRepeats( char array[], int& size );

//returns number of characters up to the null terminator, \0 int length( char array[]);

int main() { using namespace std; char array[81] = "mary had a little lamb. its fleece was white as snow."; cout

deleteRepeats( array, size);

cout

char array1[81] ="Now is the time for all good men to come to the aid of the country.";

cout

deleteRepeats( array1, size);

cout

void deleteRepeats( char array[], int& size ) { //complete the function }

int length( char array[]) { //complete the function //strings are terminated by a \0 //length is the position of '\0' }

#include //modifies 'array' to delete all instances of any duplicates 1/of characters found in 'array' void deleteRepeats' char array[], inte size ); //returns number of characters up to the null terminator, 10 int length( char array[]); int main() { using namespace std; char array(1) = "nary had a little lamb. its fleece was white as snow."; cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!