Skip to content

Commit

Permalink
Fixes NITSkmOS#44
Browse files Browse the repository at this point in the history
  • Loading branch information
kss682 committed Sep 30, 2018
1 parent 1931145 commit 45a2c14
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions binary_search.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#include<stdio.h>
#define MAX 100
void main()


void binarysearch(int array[],int x,int n)
{
int array[MAX],l,r,mid,n,x,flag=0,i;
printf("enter the no of elements\n");
scanf("%d", &n);
printf("enter the elements of the sorted array\n");
for(i=0;i<n;i++)
{scanf("%d",&array[i]);
}
printf("enter the element to be searched\n");
scanf("%d", &x);
int l,r,mid,flag=0;
l=0;
r=n-1;
mid=(l+r)/2;
Expand All @@ -34,3 +28,17 @@ if(flag==0)
printf("The element is not found\n");

}
void main()
{
int array[MAX],x,n;
printf("enter the no of elements\n");
scanf("%d", &n);
printf("enter the elements of the sorted array\n");
for(int i=0;i<n;i++)
{scanf("%d",&array[i]);
}
printf("enter the element to be searched\n");
scanf("%d", &x);
binarysearch(array,x,n);

}

0 comments on commit 45a2c14

Please sign in to comment.