ShriRam Changed status to publish July 15, 2022
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],i,search,x=0,s=0,e=9,m,n;
printf("\n Please Enter the Size of an Array : ");
scanf("%d", &n);
printf("\nPlease Enter the Array Elements : \n");
for(i=0; i<n; i++)
scanf("%d",&a[i]);
printf("Enter a value for search : ");
scanf("%d",&search);
while(s<=e) { m=(s+e)/2; if(a[m]==search) { x=1; break; } else if(a[m]>search)
{
e=m-1;
}
else if(a[m]<search)
{
s=m+1;
}
}
if(x==1)
printf("found");
else
printf("not found");
getch();
}
ShriRam Changed status to publish July 15, 2022