include<stdio.h>
include<conio.h>

void main(void)

{#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int item,lb=0,ub=9,mid;
int DATA[10]={1,2,3,4,5,6,7,8,9,10};
int beg=lb;int loc;int end=ub;
mid=(beg+end/2);
for(int i=0;i<10;i++)
{
printf("%d",DATA[i]);
printf("\nEnter item");
scanf("%d",item);
while(DATA[mid]!=item &&beg<=end)
{
if(item<DATA[mid])
end=mid-1;
else
beg=mid+1;
}
mid=(beg+end)/2;
}
if(DATA[mid]==item)
{
loc=mid;
else
printf("loc is %d",mid);
else
printf("loc is null");
}
getche();
}

include<conio.h> Non-standard, very old, not supported by modern compilers.

void main(void) Just plain wrong. C++ recognises int main()

clrscr(); Non-standard, see conio.h

scanf("%d",item); You should be passing a POINTER to item

Your if and else branches are incorrect, missing brackets and that sort of thing.

getche(); Non-standard, see conio.h

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.