Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming Projects 2 from Problem Solving with C++ by Walter Savitch part 1. D

ID: 3625053 • Letter: P

Question

Programming Projects 2 from Problem Solving with C++ by Walter Savitch
part 1.
Do Programming Project 3 in Chapter 7. In this version of the problem return a new dynamic array where all repeated letters are deleted instead of modifying the partially filled array. don't forget to free the memory allocated for these returned dynamic arrays when the data is no longer needed.

-Programming Project 3 in Chapter 7 reads...
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 may 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.

Explanation / Answer

#include void introduction(); //Explains what the program does void fill_array(char a[], int size, int& number_used); //Array a[] is filled with character data from the keyboard void delete_repeats(char a[], int& number_used); //Function will remove all repeated characters and move the rest of the characters //foward to fill in the gap. void output(char a[], int& number_used); //Outputs the contents of the array and outs the new size of the array int main() { using namespace std; char array[100]; int number_used; introduction(); fill_array(array, 100, number_used); output(array, number_used); } //uses iostream void introduction() { using namespace std; cout