Question: Using C++ //search function from slide 30 int search(const int A[], int size, int value) { int index = 0; while (index { ++index; }

Using C++

//search function from slide 30

int search(const int A[], int size, int value)

{ int index = 0; while (index

{ ++index; }

if (index

return index; return -1; }

Using C++ //search function from slide 30 int search(const int A[], int

1. Copy the search function on slide 30. Modify the search function to take as input a vector instead of an array. Remove any unnecessary arguments that were passed to the function 2. Write a printVector function which takes a vector and prints the contents of the vector. . Write a main function that create a vector of integers called grades with contents {100, 95, 87, 92, 79).Then it prompts the user to enter a number and searches the vector for that number. If the number is in the vector, it prints out to the user the position it found it at. If the number is not in the vector, it prints out that it did not find it and prints the contents of the vector using printVector. For example, if the user enters 7, the program will print out "Sorry, 7 was not found. Vector contents: 100, 95, 87, 92,79.". If the user enters 95, the program will print out "Success. Found 95 at position 2 of the vector

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!