Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

printf("Enter the number to be searched from the list:\n");

scanf("%d", &search);

first = 0;

last =999;

middle = (first+last)/2;

while (first <= last)

if(a[middle] < search)

first = middle + 1;

else if(a[middle] == search)

printf("%d found at location %d\n", search, middle+1);

break;

else

last = middle - 1;

middle = (first + last)/2;

if(first > last)

printf("No");

You might also like