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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!