#include<stdio.h>
#include<conio.h>
int a[10];
void main()
{
int low,mid,high,x,i;
clrscr();
printf("enter the 10 elements in an order\n");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
low=0;
high=10;
printf("enter the search element");
scanf("%d",&x);
if(bin(x,low,high)==-1)printf("not found");
else printf("found at the position %d",1+bin(x,low,high));
getch();
}
bin(int x,int low,int high)
{
int mid;
if(low>high) return -1;
mid=(low+high)/2;
return (x==a[mid])?mid:(x>a[mid])?bin(x,mid+1,high):bin(x,low,mid-1);
}
