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:
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
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
ABSOLUTE C++ -TEXT
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Vector Mechanics For Engineers
Vector Mechanics for Engineers: Statics and Dynamics
Fluid Mechanics: Fundamentals and Applications
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (8th Edition)
- 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…arrow_forwardWrite a function template that gets an array of generic type T as well as the number of items within the array, calculates the standard deviation of the items within the array and returns it. The user will first give an integerItemCount value (int) and that many integer values (all ints). Then, the user will give a doubleItemCount value (int) and that many double values (all doubles). Then, the program will use the function template to calculate the standard deviations of both arrays and print them out as first the standard deviation of the int array, then the standard deviation of the double array. Standard deviation of an array with size N, values are given as , and arithmetic mean as μ can be calculated as: Requirements: You MUST define and use a function template that takes an array of generic type T and an integer which defines the size of the array Getting all the user input, calling the appropriate version of the function via the template and printing the output should be done…arrow_forwardWrite a function reportDuplicates() that takes a two di mensional integer array as a parameter and identifies the duplicate valuesin the array. The function then reports these to user. Sample input and corresponding output:How many rows? 5How many columns? 2Let’s populate the array:1 86 97 312 522 4Thank you, there are no duplicate elements!How many rows? 3How many columns? 4Let’s populate the array:3 7 5 76 9 7 38 5 12 6Thank you, 3 appears 2 times, 7 appears 3 times, 5 appears 2 times,and 6 appears 2 times.arrow_forward
- In java Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated. Develop a function that returns true if the elements are in decreasing order and false otherwise. A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks. Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8, 1, 4, 6}, the function would return 6, since the subsequence {1, 4, 6} is the longest that is strictly increasing. Develop a function that takes a string…arrow_forwardWrite a function removeDuplicates -PHP( arr) that takes an associative array as a parameter and returns the same associative array except with all duplicate values removed. You may not use the function array_unique for this problem. For example:$arr = array( 'a' => "one", 'b' => "two", 'c' => "three", 'd' => "two", 'e' => "four", 'f' => "five", 'g' => "three", 'h' => "two" ); Expand (10 lines) print_r(removeDuplicates( arr)); Would print: Array ( [a] => one [e] => four [f] => five )arrow_forwardWrite a function averageCatAge() that takes an array of cat structs (cat* a_cats) and the size of the array (unsigned int numCats) as input parameters. The function then returns the mean or average age for all the cats...the average is ..... the sum of values divided by the number of valueS just in case you forgot. The average returned is a double.arrow_forward
- Create a program that accepts an integer N, and pass it to the function generatePattern. generatePattern() function which has the following description: Return type - void Parameter - integer n This function prints a right triangular pattern of letter 'T' based on the value of n. The top of the triangle starts with 1 and increments by one down on the next line until the integer n. For each row of in printing the right triangle, print "T" for n times. In the main function, call the generatePattern() function. Input 1. One line containing an integer Output Enter N: 4 T TT TTT TTTTarrow_forwardWrite a function name “computer Two” that accepts four parameters: A1: array of type integer A2: array of type integer S1: number of elements in A1 Array S2: number of elements in A2 Array The function must return true if the sum of A1 equals than the sum of A2 , otherwise it must return false .arrow_forwardNothing too advanced pleaseC++arrow_forward
- Define a function named “getExamListInfo” that accepts an array of Exam objects and its size. It will return the following information to the caller: - The number of exams with perfect score - The number of exams with “Pass” status - The index of the Exam object in the array that has the largest score. For example, if you get the exam info for this array of Exam object Exam examList[] = { {"Midterm1 Exam", 90}, {"Midterm2 Exam", 80}, {"Final Exam", 50}, {"Extra Credit", 100}, {"Initial Test", 0}, {"Homework1", 69} } ; You will get Perfect Count: 1 Pass Count: 3 Index of the largest: 3 C++arrow_forwardWrite a program that creates a 2D array of integers of size nXn initialized with test data.The program should have the following functions:● getTotal. This function should accept a 2D array as an argument and returnthe total of all the values in the array.● getAverage. This function should accept a 2D array as an argument and returnthe average of all the values in the array.● getRowTotal. This function should accept a 2D array as the first argument andan integer as its second argument. The second argument should be the subscriptof a row in the array. The function should return the total of the values in thespecified row.● getColumnTotal. This function should accept a 2D array as the first argumentand an integer as its second argument. The second argument should be thesubscript of a column in the array. The function should return the total of thevalues in the specified column.● getHighestInRow. This function should accept a 2D array as the firstargument and an integer as its second…arrow_forwardWrite a modular program that analyzes a year’s worth of rainfall data. In addition to main, the program should have a getData function that accepts the total rainfall for each of 12 months from the user and stores it in an array holding double numbers. It should also have four value-returning functions that compute and return to main the totalRainfall, averageRainfall, driestMonth, and wettestMonth. These last two functions return the number of the month with the lowest and highest rainfall amounts, not the amount of rain that fell those months. Notice that this month number can be used to obtain the amount of rain that fell those months. This information should be used either by main or by a displayReport function called by main to print a summary rainfall report similar to the following: 2019 Rain Report for Springdale County Total rainfall: 23.19 inches Average monthly rainfall: 1.93 inches The least rain fell in January with 0.24 inches. The most rain fell in April with 4.29…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education