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)



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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
