Question
Given below is the definition of a function named linSearch that takes an array of int values, size of the array, and a search value
Given below is the definition of a function named linSearch that takes an array of int values, size of the array, and a search value of type int. The function finds if the search value exists in the given array. If the search value exists in the given array, the function returns true, else returns false.
bool linSearch(int array [], int size, int searchVal) {
bool flag = false;
for( int i = 0; i < size; i++) {
if (searchVal == array[i]) {
flag = true;
break; } }
return flag; }
Write the above function as a function template with the same name so that the function template can be specialized (used) with different numerical data types (int, float, double, long).
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