Binary search bool type

include
#include
using namespace std;

int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[n];
}
int key;
cin>>key;
bool present = binary_search(a,a+n,key);

if(present==false){
    cout<<"-1"<<endl;
}
return 0;

}
//mistake?

hi @srivastavaayush1611_3fd51b257da0b834 cin>>a[i] not a[n]

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.