#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,f=0,b,min,max,mid;
clrscr();
for(i=0;i<5:i++)
{
printf("enter number");
scamf("%d",&a[i]);
}
printf("enter search value");
scanf("%d",&b);
min=0;
max=4;
while(min<=max)
{
mid=(min+max)/2;
if(a[mid] <=b)
min=mind+f;
else
max=mid-j;
if(a[mid] == b)
f=1;
break:
}
if(f==1)
printf("FOUND");
else
printf("NOT FOUND");
getch();
}
No comments:
Post a Comment