From fd4e9eccbdc3f531b8f5dbf3d45adac4a44e1b10 Mon Sep 17 00:00:00 2001
From: astral29 <57220751+astral29@users.noreply.github.com>
Date: Thu, 31 Oct 2019 17:55:37 +0530
Subject: [PATCH] binary_search.c

---
 binary_search.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 binary_search.c

diff --git a/binary_search.c b/binary_search.c
new file mode 100644
index 0000000..229f8b0
--- /dev/null
+++ b/binary_search.c
@@ -0,0 +1,27 @@
+#include<stdio.h>
+int main()
+{
+	int arr[11]={2,6,12,25,49,65,78,80,85,90,98},beg=0,end=10,loc,item,mid;
+	printf("enter the item yuo want to search\n");
+	scanf("%d",&item);
+	mid=(beg+end)/2;
+	while(beg<=end&&arr[mid]!=item)
+	{ 
+       if(item>arr[mid])
+	   {
+	    	beg=mid+1;
+	   }
+	   else
+	   {
+	   	    end=mid-1;
+	   }
+	   	mid=(beg+end)/2;
+    }
+       if(item==arr[mid])
+	     {
+		    loc=mid;
+		    printf("item found at index=%d\n",loc);
+	     } 
+	     else
+	     printf("item not found\n");
+}