#include
using namespace std;
int binary_search( int arr[],int size,int key){
int mid,start,end;
start=0;
end=size-1;
while(start>=end){
mid=(start+end)/2;
if(arr[mid]==key)
{
return mid;
}
else if (arr[mid]<key)
{
start=mid+1;
}
else
{
end=mid-1;
}
}
return -1;
}
int main(){
int key;
int arr[5]={2,4,6,8,10};
cout<<“enter the value you want to search in an array”<<endl;
cin>>key;
cout<<binary_search( arr,5,key);
return 0;
}