title: How does the return statement work in recursion?
body: <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  int binarySearch(int a[], int size, int x, int low, int high){
      if(low &gt; high) return -1;
  
      int mid = (low + high)/2;
  
      if(a[mid] == x){
          return mid;
      }
  
      if(a[mid] &lt; x){
          return binarySearch(a, size, x, mid+1, high);
      }
      else{
          return binarySearch(a, size, x, low, mid-1);
      }
  }
  
  int main(){
      int a[] = {1, 2, 3, 4, 5, 6};
      int size = sizeof(a) / sizeof(a[0]);
      cout&lt;&lt;binarySearch(a, size, 5, 0, size-1);
  }
  </code></pre>
  <p>For example in this program that performs Binary search using recursion, I am confused in the usage of return keyword in the statement <code>return binarySearch(a, size, x, mid+1, high);</code>.</p>
  <p>Ignoring the fact that not writing the return keyword in this statement gives a warning, what will be the difference if i dont write return here.
  Would it be different internally or its the same thing.
  In what cases does the return statement become useful in such statements.</p>