Given the following function definition, what modifications need to be made to the search function so that it finds all occurrences of target in the array? int search(const int array[], int target, int numElements) { int index=0; bool found=false; while((!found) && (index < numElements)) { if(array[index] == target) found=true; else index++; } if(found==true) return index; else return -1; } a. Add another parameter to indicate where to stop searching b. Add another parameter to indicate where to start searching c. This already can find all occurrences of a given target d. Have the function return the whole array

Respuesta :

Answer:

The answer is "Option b".

Explanation:

In the given question, a function "search" is defined. That searches element that is passed in the function by parameter. To search more quickly we must add another parameter in the function. and other options are not correct that can be described as:

  • In option a, We add another element in parameter to start searching not to stop.
  • In option c, The function can not find an element that occurs in the array target.
  • In option d, Function will not return array it will return only index value.

ACCESS MORE