title: How can I simplify this working Binary Search code in C?
body: <p>Hey guys started programming in C few weeks ago learning about algothiritms, just wondering how would you make my code more simple its just a binary search function. But the only thing is you must keep the arguments the same, thanks in advance.</p>
  
  <pre><code>bool search(int value, int values[], int n)
  {
      int min = values[0];
      int max = values[n-1];
      int average = (min + max) / 2;
  
      if(average == value)
      {
          return true;
      }
  
      while (average &gt; value) 
      {
          max = average - 1;
          average = (min + max) / 2;
  
      }
  
      while (average &lt; value)
      {
          min = average + 1;
          average = (min + max) / 2;
      }
  
      if (max &lt; min) 
      {
          return false;
      }
      if (average == value) {
           printf("%i\n", average);
          return true;
      }
      else
      {
          return false;
      }
  }
  </code></pre>