The program works...however for the question it states
"The function should print true if the value is found in the array or false if the value is not found in the array."
Would this be the way of doing it:
Code:
bool isMember(int a[], unsigned int size, int val);
using namespace std;
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
int main()
{
int numbers[10] = {1,2,4,7,9,11,14,15,17,19};
int guess;
std::cout<<"Enter Any Number Between 1-20: ";
std::cin>>guess;
std::cout<<("\n");
if (isMember(numbers, 10, guess))
{
std::cout << "The number was found\n";
}
else
{
std::cout << "The number was not found\n";
}
}
bool isMember(int a[], unsigned int size, int val)
{
int i;
for (i = 0; i < size; i++ )
{
if (a[i] == val)
{
return true;
}
}
return false;
}