Question: Program must be written in C++: Write a recursive Boolean function isMember. The function should accept two arguments: an array and a value. The function
Program must be written in C++:
Write a recursive Boolean function isMember. The function should accept two arguments: an array and a value. The function should return true if the value is found in the array, false if the value is not found in the array. Complete the following program by adding isMember function definition and testing it.
#include
using namespace std;
const int ARRAY_SIZE = 10;
// Function prototype
bool isMember(int [], int, int);
int main()
{ // Create an array with some values in it.
int numbers[ARRAY_SIZE] = {2, 4, 6, 8, 10, 12, 14, 16 ,18, 20 }; // Search for the values 0 through 20 in the array.
for (int x = 0; x <= 20; x++)
{ if (isMember(numbers, x, ARRAY_SIZE))
cout << x << " is found in the array. ";
else cout << x << " is not found in the array. "; }
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
