Absolute C++
Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
bartleby

Videos

Textbook Question
Book Icon
Chapter 5, Problem 2PP

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:

Chapter 5, Problem 2PP, Write a function called deleteRepeats that has a partially filled array of characters as a formal

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.

Blurred answer
Students have asked these similar questions
Write a function numberOfOccurences() which takes an integer reference array of size 10 and a search value as parameters and returns the number of occurrences of the value inside the array. Test your function. Initialize an array that contains the following numbers: 4, 7, 2, 8, 8, 1, 4, 8, 9, 1. Then test it with search values 1, 8 and 6. Your program output should look like the following: [4 7 2 8 8 1 4 8 9 1 ]1 occurs 2 times in the array.8 occurs 3 times in the array.6 occurs 0 times in the array.   C++ Nothing too advanced please
You can prevent a function from changing the actual parameter of an array by: Select one: a. passing the array by value b. using const in the declaration of the formal parameter c. individually declaring all the elements as constants d. using static in the declaration of the formal parameter
Suppose that an array is passed as a parameter. How does this differ from the usual use of a value parameter? When an array is passed as a parameter, it is like passed by reference. A new array will be created in the called function and any changes to the new array will pass back to the original array. When an array is passed as a parameter, it is passed by value. So any changes to the parameter do not affect the actual argument. When an array is passed as a parameter, changes to the array affect the actual argument. This is because the parameter is treated as a pointer that points to the first component of the array. This is different from a value parameter (where changes to the parameter do not affect the actual argument). When an array is passed as a value, changes to the array affect the actual argument. This is because the parameter is treated as a pointer that points to the first component of the array. This is different from a parameter (where changes to the parameter do not…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License