Why some cses are passing others not

@sattyrajpoot39 there is some modification required in your code
mid=(s+e)/2;
In the first if
ans=mid;
use if condition instead of else if
and give this condition
s=mid+1;
and also do <=n in both if statement.