Question: (I need help with this code. You only have to do the TODO parts) 30 points You are required to write a function trim that

(I need help with this code. You only have to do the TODO parts)

(I need help with this code. You only have to do the

TODO parts) 30 points You are required to write a function trim

that takes three arguments: an in- teger array, its length, and a

30 points You are required to write a function trim that takes three arguments: an in- teger array, its length, and a target value; and returns void. Your algorithm is supposed to modify the array (and its length) by removing all of the elements of the array from (and including) the first occurrence of the target value. If the target value is not present in the array then this function keeps the array unchanged (i.e. nothing happens). Your function must deallocate (free) any heap memory that is no longer required. Example A. Input array {3, 2, 5, 1, 0, 8, 0, 4} Array length = 8 Target value = 0 // Call to function trim Array after trimming = {3, 2, 5, 1} Array length = 4 Example B. Input array = {3, 2, 5, 1, 0, 8, 0, 4} Array length = 8 Target value = 33 // Call to function trim Array after trimming = {3, 2, 5, 1, 0, 8, 0, 4} Array length = 8 9 #include 10 11 using namespace std; 12 13 /* 14 * TODO your function header goes here 15 16 17 void testPrint(int *pe, int length); 18 19 int main() { 20 21 int __test() - {3, 2, 5, 1, 2, 8, 4); 22 int test_length - 7; 23 24 25 26 Test 1 27 */ 28 cout > 3 2 5 1 " >"; 64 for(int 1.0;

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!