#include using namespace std; int binary_search(int a[],int l,int r,int key){ while(l<=r){ int m = l+(r-l)/2; if(key==a[m]) return m; else if(key>n; cout<<"Enter array elements: "; int a[n]; for (int i = 0; i < n; ++i) { cin>>a[i]; } cout<<"Enter search key: "; cin>>key; int res = binary_search(a,0,n-1,key); if(res != -1) cout<