From 657d979f923458cf257e54beeb03bd395f4e8e4d Mon Sep 17 00:00:00 2001 From: Pankaj Chaudhary Date: Wed, 3 Oct 2018 12:36:18 +0530 Subject: [PATCH 1/2] Create binarys.c --- Searches/binarys.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Searches/binarys.c diff --git a/Searches/binarys.c b/Searches/binarys.c new file mode 100644 index 00000000..9e64089b --- /dev/null +++ b/Searches/binarys.c @@ -0,0 +1,38 @@ + #include + + int main() + { + int c, first, last, middle, n, search, array[100]; + + printf("Enter number of elements\n"); + scanf("%d",&n); + + printf("Enter %d integers\n", n); + + for (c = 0; c < n; c++) + scanf("%d",&array[c]); + + printf("Enter value to find\n"); + scanf("%d", &search); + + first = 0; + last = n - 1; + middle = (first+last)/2; + + while (first <= last) { + if (array[middle] < search) + first = middle + 1; + else if (array[middle] == search) { + printf("%d found at location %d.\n", search, middle+1); + break; + } + else + last = middle - 1; + + middle = (first + last)/2; + } + if (first > last) + printf("Not found! %d isn't present in the list.\n", search); + + return 0; + } From 167ab428d87ecc0cf5d2f9481ef01604a18396b2 Mon Sep 17 00:00:00 2001 From: Ashwek Swamy <39827514+ashwek@users.noreply.github.com> Date: Mon, 11 Feb 2019 05:32:54 +0530 Subject: [PATCH 2/2] Rename Searches/binarys.c to searching/binarys.c --- {Searches => searching}/binarys.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {Searches => searching}/binarys.c (100%) diff --git a/Searches/binarys.c b/searching/binarys.c similarity index 100% rename from Searches/binarys.c rename to searching/binarys.c