title: Using binary search to find the square root of a number in C
body: <p>Trying to work out the square root of a number using binary search, however my implementation of it is not working and i'm not sure why - any help appreciated, thank you</p>
  
  <p>Heres my code. 'end' being the value of the number I want to be square rooted</p>
  
  <pre><code> while(start &lt;= end) {
     float mid = ((start + end) / 2);
     printf("\nhalving mid");
  
     if(mid * mid == end){
        sqrt = mid;
        printf("\nsqrt = %d", sqrt);
     }
     if(mid * mid &lt; end){
       start = mid + 1;
       sqrt = mid; 
       printf("\nsqrt: %d", sqrt);
     }
     else{
       start = mid - 1;
     }
   }
  </code></pre>