From 84922d5fa9ba462a3aa2a725ceff5aa70563deda Mon Sep 17 00:00:00 2001 From: "Alfin S. Thomas" Date: Wed, 24 Oct 2018 19:28:56 +0530 Subject: [PATCH] made the Binary Search larger added limits.h to use MAX_NAME to increase the max limit of the array from 20 to max! --- bsearch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bsearch.c b/bsearch.c index 4447316..b7656f5 100644 --- a/bsearch.c +++ b/bsearch.c @@ -1,7 +1,11 @@ +//This program is used to implement Binary Search in an Array of MAX size 20 +//To make it more better we are going to add limits #include +#include + main() { - int a[20],i,n,p,low=0,high=0,mid=0; + int a[NAME_MAX+1],i,n,p,low=0,high=0,mid=0; // by doing this the size of array is maxed out printf("\nEnter the no. of elements in the array:"); scanf("%d",&n); printf("\nEnter the sorted array:"); @@ -11,6 +15,7 @@ main() mid=n-1/2; printf("\nEnter the no. to be searched:"); scanf("%d",&p); + //Binary Searching while(low<=high) { if(p