diff --git a/binary.cpp b/binary.cpp new file mode 100644 index 0000000..3a22b27 --- /dev/null +++ b/binary.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; + +int binarysearch(int arr[],int beg,int end,int info) +{ + int mid=(beg+end)/2; + do + { + mid=(beg+end)/2; + if(infoarr[mid]) + { + beg=mid+1; + } + + else if(arr[mid]==info) + { + return mid; + } + + }while(beg<=end); + cout<<"value not found"<>size; + int arr[size]; + + cout<<"Enter elements of array"<>arr[i]; + + cout<<"Enter item to search"<>x; + + sort(arr,arr+size); + + int y=binarysearch(arr,0,size-1,x); + if(y!=-1) + cout<<"value found"<