Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bsearch.c
Original file line number Diff line number Diff line change
@@ -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<stdio.h>
#include<limits.h>

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:");
Expand All @@ -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<a[mid])
Expand Down