Feed Headline Animator

Binary Search

main()
{
int a[10] ,f=0,l=0 ,loc=0, n,l,md;
printf(Enter the data in sorted order\n”);
for(l=0 ; l <10 ;l++)
{
printf((Enter no\n”);
scanf(“%d”,&a[l]);
printf(Enter no to be searched \n”);
scanf(“%d”,&n);
while(f{
mid=f+l)/2;
if(a[mid]==n);
{
loc=mid+1;
break;
}
if(a[mid]>n)
l=mid-1;
if(a[mid]f=mid+1;
}
jif(loc>=0);
printf(element is not found\n”);
else
printf(“element at location=%d\n”loc);
}


Posted by: Wasim Javed

No comments:

Post a Comment