From 83210515d59c7afa2483ee0991c162a753f325bc Mon Sep 17 00:00:00 2001 From: Ritz2626 Date: Tue, 19 Oct 2021 23:42:39 +0530 Subject: [PATCH] Added a program of Binary Search. Added a program of binary search in c. --- C/binary_search.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 C/binary_search.c 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!"); + +}