diff --git a/binary_Search.cpp b/binary_Search.cpp new file mode 100644 index 0000000..f3d5478 --- /dev/null +++ b/binary_Search.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; + +int main() +{ + int count, i, arr[30], num, first, last, middle; + cout<<"how many elements would you like to enter?:"; + cin>>count; + + for (i=0; i>arr[i]; + } + cout<<"Enter the number that you want to search:"; + cin>>num; + first = 0; + last = count-1; + middle = (first+last)/2; + while (first <= last) + { + if(arr[middle] < num) + { + first = middle + 1; + + } + else if(arr[middle] == num) + { + cout< last) + { + cout<