Programming Language: C++ Please provide notes for understanding. 7.3: Delete Repeats Write a function called delete_repeats 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 (Links to an external site.) a[10]; a[0] = 'a'; a[1] = 'b'; a[2] = 'a'; a[3] = 'c'; int (Links to an external site.) size = 4; delete_repeats(a, size);  (Links to an external site.) 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 test program that reads all the characters on a line(up to but and including the newline character) and stores all of them EXCEPT the newline character in an array. Assume no more than 80 characters per line. The test program keeps count of the number of characters actually stored in the array. The test program prints out the number of characters stored and then prints out the characters on a single line twice. The program then passes the array to the function delete_repeats and now prints the characters effectively stored in the array on a single line followed by the number of characters that are effectively stored in the array. Sample Output: Enter a line:abca baaxycz 12 abca baaxycz abca baaxycz abc xyz 7

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Programming Language: C++

Please provide notes for understanding.

7.3: Delete Repeats

Write a function called delete_repeats 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 (Links to an external site.) a[10];

a[0] = 'a';

a[1] = 'b';

a[2] = 'a';

a[3] = 'c';

int (Links to an external site.) size = 4;

delete_repeats(a, size);

 (Links to an external site.)

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 test program that reads all the characters on a line(up to but and including the newline character) and stores all of them EXCEPT the newline character in an array. Assume no more than 80 characters per line. The test program keeps count of the number of characters actually stored in the array.

The test program prints out the number of characters stored and then prints out the characters on a single line twice. The program then passes the array to the function delete_repeats and now prints the characters
effectively stored in the array on a single line followed by the number of
characters that are effectively stored in the array.

Sample Output:

Enter a line:abca baaxycz
12
abca baaxycz
abca baaxycz
abc xyz
7

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY