#include <stdio.h>
int main() {
int data[10] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
int num = 7;
int low,high,mid;
low = 0;
high = 9;
while(low <= high){
mid = (low + high) / 2;
if(num == data[mid]){
printf("%d ",mid);
return 0;
}
else if(num > data[mid]){
low = mid + 1;
}
else if(num < data[mid]){
high = mid - 1;
}
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: