#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10],i,n,first,last,mid;
cout<<"Enter elements of the array:"<<endl;
for(i=0;i<10;i++)
{
cout<<"Enter element no."<<i+1<<": ";
cin>>a[i];
}
first=0;
last=9;
cout<<"Enter element to be searched:";
cin>>n;
do
{
mid=(first+last)/2;
if(a[mid]==n)
break;
if(a[mid]>n)
last=mid-1;
else
first=mid+1;
}
while(first<=last);
if(a[mid]==n)
cout<<"Element is present in the array.";
else
cout<<"Element not present in array.";
gotoxy(25,24); cout<<"Press any key to continue......";
getch();
}