title: Binary Search in C plus plus
body: <p>the code when executes creates an infinite loop.</p>
  <p>What is wrong with this code :-(</p>
  <pre><code>using namespace std;
  
  int main(){
   int arr[10]={1,20,30,75,90,189,253,302,304,455}, start=0, end=9, item, mid, i;
   cin&gt;&gt;item;
   mid=(start+end)/2;
   while(arr[mid]!=item){
       mid=(start+end)/2;
       if(item&gt;mid){
           start=mid+1;
       }
       else if(item&lt;mid){
           end=mid-1;
       }
   }
   cout&lt;&lt;&quot;Found at location : &quot;&lt;&lt;mid&lt;&lt;endl;
   return 0;
  }
  </code></pre>