[RESOLVED] Help writing code.
value Write a function, contains, that accepts an array of integers, the number of elements in the array and an integer value, and returns a boolean value indicating whether the value appears as an element of the array (arrays as parameters, basic search algorithm)
bool contains(int a[], int n, int val)
{
for(int i = 0; i < n; i++)
{
if(a[i] == val)
{
return = true;
}
}
}
what am i doing wrong..
Re: [RESOLVED] Help writing code.
Quote:
Originally Posted by
mejiac3
what am i doing wrong..
Re: [RESOLVED] Help writing code.
You also miss a return false; at the end of the function but your compiler has probably already told you that.