Why these 2 codes are not working?

Why these 2 codes are not working?


@cbcao263
The given input array is not sorted. you can’t apply binary_search() over unsorted function.
So please sort the given array first.



I have changed in both, Now Please check that.

@cbcao263
In first code, there are few mistake

  1. line 14 should be s=mid+1;
  2. line 18 should be e=mid -1;
  3. you have not taken input q. Just write cin>>q; after line 37

@cbcao263
In second code, you have missed cin>>q;
your code will work after this change

@cbcao263
I think you got 100 score. Please mark this doubt as resolved. Thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.