title: Cannot find the position of an element inside a descending order array (binary search)
body: <p>i think the logic is completely fine yet i do not know why the code does not return the position of a given element inside the descending order array using binary search.</p>
  
  <pre><code>#define n 9
  bool found = false;
  int binarysearch(int array[n],int element){
  int start = 0;
  int end = n-1;
  int mid;
  while(start&lt;=end &amp;&amp; !(found)){
  mid = start + end / 2;
  if(element==array[mid])
  found=true;
  else if(element&lt;array[mid]) {
  start = mid + 1;
  else
  end = mid - 1;
  }
  if(found)
  return mid;
  else
  return -1;
  }
  int main (){
  int array[n]={10,9,8,7,6,5,4,3,2};
  cout &lt;&lt; "Enter the element you want to find the position in the array " &lt;&lt; endl;
  int x;
  cin &gt;&gt; x;
  int index = binarysearch(array,x);
  if(index!=-1)
  cout &lt;&lt; index &lt;&lt; endl;
  else
  cout &lt;&lt; "index not found"&lt;&lt;endl;
  </code></pre>
  
  <p>so whenever i input the element the result is just empty.</p>