Linear search using array reference passing to function
Search for presence of element in an integer array by using a function with a call by reference of array, size and search term.
using namespace std;
bool search(int ,int, int);
cout<<"Enter search term ";
cout<<"Element not found"<<endl;
bool search(int AR,int size,int item)
if(AR[i]==item) return true;
When array is passed as a reference in a target function, its size can not be automatically determined using sizeof operator as only the location of first member of array is passed. Therefore the size of array has to be essentially passed to the target function.
Suggested Filename(s): linearsearchfunc.cpp, searchfunc.cpp, arrrefpassing.cpp
sunmitra| Created: 4-Dec-2017 | Updated: 8-Dec-2017|