Question: Exercise #2: Location of Target Write a function named location_of_target that takes as its arguments the following: . a one dimensional array of integer values

 Exercise #2: Location of Target Write a function named "location_of_target" that

Exercise #2: Location of Target Write a function named "location_of_target" that takes as its arguments the following: . a one dimensional array of integer values an integer that tells how many integer values are in the array; an integer "target value" The function should determine whether the given target value occurs in any of the cells of the array, and if it does, the function should return the subscript (index) of the cell containing the target value. If more than one of the cells contains the target value, then the function should return the largest subscript of the cells that contain the target value. If the target value does not occur in any of the cells, then the function should return the sentinel value-1. Thus, for example, if the target value that's passed to the function is 34 and the array thair's passed to the function looks likethis 0 2 3 56 58 26 91 34 70 34 88 then the target value occurs in cells 3 and 5, so the function should return the integer value 5 Sample input/output: e rightnost location of the target 15

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!