Answered step by step
Verified Expert Solution
Link Copied!

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; }

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

What is topology? Explain with examples

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago