Does the binary search algorithm always return the number less than the given number if the given number is missing? : <p>If I perform binary search on an array, such that my required number is missing does the mid eventually point to the number less than the required number?
This is my code-</p>

<pre><code>void binarySearch(int a[],int n,int x)
{
    int start=0;
    int end=n-1;
    while(start&lt;=end)
    {
        int mid=(start+end)/2;
        if(a[mid]==x)
        {
            break;
        }
        else if(a[mid]&lt;x)
        {
            start=mid+1;
        }
        else
        {
            end=mid-1;
        }
    }
    cout &lt;&lt; a[mid] &lt;&lt; endl;
}
</code></pre>

<p>Can this result be generalized?</p>
