diff --git a/C/binary_search.c b/C/binary_search.c new file mode 100644 index 0000000..05d0bc8 --- /dev/null +++ b/C/binary_search.c @@ -0,0 +1,36 @@ +#include +int a[20]; +void main() +{ + int n; + printf("Enter the size of the array\n"); + scanf("%d",&n); + printf("Enter the elements in the array"); + for(int x=0;xa[mid]) + first=mid+1; + else + { + pos=mid; + break; + } + } + if(pos!=-1) + printf("Element %d found at position %d",ele,pos); + else + printf("Element not found!"); + +}