Technicalsymposium.com-Free Email Alerts


Enter Your Email :

Important Note:Login & Check Your Email Inbox and Activate Confirmation Link

Subscribe & Get All Fresher Jobs Information & Study Materials PDF and Projects- Free Download

C Programming Books PDF


C Aptitude Question Papers


Datastructure Programming in C



C Programming & Tech Interview Materials PDF- Free Download

C Program For BINARY SEARCH.

void main()

{

int n,i,search,f=0,low,high,mid,a[20];

clrscr();

printf("Enter the n value:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

printf("Enter the number in ascending order a[%d]=",i);

scanf("%d",&a[i]);

}

printf("Enter the search element:");

scanf("%d",&search);

low=1;

high=n;

while(low<=high)

{

mid=(low+high)/2;

if(search
{

high=mid-1;

}

else if(search>a[mid])

{

low=mid+1;

}

else

{

f=1;

printf("obtainedin the position %d:",mid);

getch();

exit();

}

}

if(f==0)

{

printf("not present");

}

getch();

}

Download All C Programming & Study Materials PDF