void main()
{
int i,a[50],low,n,high,mid,ser;
clrscr();
printf("Enter the limit");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the elements");
scanf("%d",&a[i]);
}
printf("searched");
scanf("%d",&ser);
low=0;
high=n-1;
while(low<=high)
{
mid=low+high/2;
}
if(a[mid]==ser)
{
printf("%d",mid);
}
else if(a[mid]>ser)
{
high=mid-1;
}
else
low=mid+1;
if(low>high)
printf("not");
No comments:
Post a Comment