#include<stdio.h>
#include<conio.h>
int binarysearch(int,int[],int);
void main()
{
int a[10],i,item,n;
clrscr();
printf("enter the size of the array:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Element[%d]:",i);
scanf("%d",&a[i]);
}
printf("\n enter ther item to be searched:");
scanf("%d",&item);
binarysearch(n,a,item);
getch();
}
int binarysearch(int n,int a[],int item)
{
int beg=1,end=n,mid;
while(beg<=end)
{
mid=(beg+end)/2;
if(item==a[mid])
{
printf("item %d is found at location %d",item,mid);
return;
}
if(item > a[mid])
{
beg=mid+1;
}
else
end=mid-1;
}
printf("\n item %d is not found",item);
return;
}
#include<conio.h>
int binarysearch(int,int[],int);
void main()
{
int a[10],i,item,n;
clrscr();
printf("enter the size of the array:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Element[%d]:",i);
scanf("%d",&a[i]);
}
printf("\n enter ther item to be searched:");
scanf("%d",&item);
binarysearch(n,a,item);
getch();
}
int binarysearch(int n,int a[],int item)
{
int beg=1,end=n,mid;
while(beg<=end)
{
mid=(beg+end)/2;
if(item==a[mid])
{
printf("item %d is found at location %d",item,mid);
return;
}
if(item > a[mid])
{
beg=mid+1;
}
else
end=mid-1;
}
printf("\n item %d is not found",item);
return;
}
We are urgently in need of KlDNEY donors for the sum of $500,000.00 USD, Email for more details:
ReplyDeletehospitalcarecenter@gmail.com
WhatsApp +91 779-583-3215
ReplyDeleteKidney donor needed urgently at Apollo Hospital, we offer huge amount for one kidney only contact me via WhatsApp number: +918122208392 Email: apollohospitalkidneydep@gmail.com
Kidney donor needed urgently at Apollo Hospital, we offer huge amount for one kidney only contact me via WhatsApp number: +918122208392 Email: apollohospitalkidneydep@gmail.com
ReplyDeleteKidney donor needed urgently, My client is urgently in need of a kidney transplant, If interested to sell contact here on my what'sApp number +4915219253693 Or Email: kidneydeal@gmail.com
ReplyDeleteKidney donor needed urgently, we offer huge amount for one kidney only contact me via WhatsApp number: +918122208392 Email: apollohospitalkidneydep@gmail.com
ReplyDelete