#include<iostream.h>
#include<conio.h>
int main()
{
int a[100], n, i, item, beg, end, mid;
clrscr();
cout<<"Enter the number of elements : ";
cin>>n;
cout<<endl<<"Enter the numbers in ascending order : "<<endl;
for(i=0; i<=n-1; i++)
{
cin>>a[i];
}
cout<<"Enter the no. to be searched : ";
cin>>item;
beg = 0;
end = n-1;
mid = (beg+end)/ 2;
while (beg<=end && item !=a[mid])
{
if (item > a [mid])
beg= mid + 1;
else
end = mid - 1 ;
mid = (beg + end) / 2;
}
if(a[mid]==item)
cout<<endl<<item<<" is found in position "<<mid+1;
else
cout<<endl<<"Item does not exist";
getch();
return 0;
}