This is direction. isMember function Write a boolean function named isMember tha
ID: 3540007 • Letter: T
Question
This is direction. isMember function Write a boolean function named isMember that takes three arguments: an array, its size (number of elements) and a value. It should return true if the value is found in the array, or false if the value is not found in the array. igonore somoe powerfunction and those stuff those functions are working but. searching in array has problem . my coding is not work actually. i dont know why, i got random number after compiling. please help me and tell me what is wrong thanks u! ************************************************************************************************ Here is my code~ bool isMember(int array[],int size, int value) { bool status=false; if(size<=0) return false; else { if(array[size-1]==value) return true; else isMember(array,size-1,value); } } int main() { float m=2; int n=5; float result; int array[size]={1,2,3,4,5}; int x=4; int answer; cout<<"Table of Squares:"<Explanation / Answer
//Return is missed inside function call. Change is highlighted in bold
bool isMember(int array[],int size, int value)
{
bool status=false;
if(size<=0)
return false;
else
{
if(array[size-1]==value)
return true;
else
return isMember(array,size-1,value);
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.