I am having trouble with a linear search algorithm function that I have to write for a program. The direction for this function states:
A linear search algorithm, where x is the searched item in vector v. It simply starts searching for x from the beginning of the vector v to the end, but it stops searching when there is a match. If the search is successful, it returns true; otherwise, it returns false. To implement this routine, simply call the find ( ) function in the STL.
Below is what I have and it keeps printing out zeros instead of integers. Any ideas how to make it works? Thanks.
bool linearSearch ( const vector <int>& v, int x )
if find (v.begin(), v.end(), x);