Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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; }
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started