#include #include #include #include using namespace std; int key; void binarysearch(int[],int, int); void binarysearch(int ar[],int low,int high) { while(low<=high) { int mid=(low+high)/2; if(ar[mid]==key) { cout<<"element found at position:"<key) high=mid-1; else low=mid+1; } cout<<"element not found"; } int main() { int ar[20],m,i; cout<<"enter the size of array\n"; cin>>m; cout<<"enter the elements of the array\n"; for(i=0;i>ar[i]; cout<<"enter element to search"; cin>>key; binarysearch(ar,0,m); getch(); return 0; }