title: returning bool value to main c++ always returning true regardless of answer
body: <p>Im new to programming and I seem to have a problem returning the finalResult variable, every time I pass it back to main it returns true regardless of the answer being true or false but if I output in the second function I get the right answer, is it something to do with the "*result"?</p>
  
  <p>The question I received from my teacher was as follows...</p>
  
  <p>"A function HasValue that may be passed a reference to an array, the size of the array and a
  search value. The function should return true if the search value exists in the array" </p>
  
  <p>so I wrote this,</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  using namespace std;
  bool HasValue(int number, long length, int arr[], bool finalResult);
  int main(int argc, const char* argv[])
  {
  
      int num, arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
      bool result;
      auto array_length = end(arr) - begin(arr); //size of array
      cout &lt;&lt; "enter number: ";
      cin &gt;&gt; num;
      HasValue(num, array_length, arr, result);
      cout &lt;&lt; result &lt;&lt; "\n";
  
      return 0;
  }
  bool HasValue(int number, long length, int arr[], bool finalResult)
  {
  
      int* end = arr + length;
      int* result = find(arr, end, number);
      if (result != end)
          finalResult = true;
      else
          finalResult = false;
  
      return finalResult;
  }
  </code></pre>
  
  <p>I am probably doing something really silly but I cant spot it, any help is much appreciated, thank you in advance.</p>