Code:#include<stdio.h>
#include<stdlib.h>
main()
{
int count,count2,count3,count4,array[50],temp,search,high=49,low=0,location=25;
srand(2);
for(count=0;count<50;count++)
{
array[count]=rand()%1000;
}
for(count3=0;count3<count;count3++)
{
for(count2=0;count2<count-1;count2++)
{
if(array[count2]>array[count2+1])
{
temp=array[count2];
array[count2]=array[count2+1];
array[count2+1]=temp;
}
}
}
for(count2=0;count2<count;count2++)
printf("%i\n",array[count2]);
printf("Enter a number and I will tell you it's location.");
scanf("%i", &search);
while(search!=array[location]||(low-high)==1)
{
if(array[location]==search)
printf("%i was located in location %i\n",search,location);
if(array[location]!=search)
printf("Between %i and %i\n",low,high);
if(array[location]<search)
{
low=location;
location=(low+high)/2;
}
else
{
high=location;
location=(low+high)/2;
}
}