// binary search #include #include using namespace std; int main() { // ************** declaration statements *********** int numbers[] = {2, 4, 5, 11, 13, 20, 34, 39, 50, 52, 59, 64, 66, 70, 75, 76, 81, 83, 85, 92}; int first = 0; int last = 19; int mid = 0; int key = 0; bool found = false; cout << "Enter the value you would like to search for: "; cin >> key; while (first <= last && !found) { mid = (first + last) / 2; if (key > numbers[mid]) { first = mid + 1; } else if (key < numbers[mid]) { last = mid - 1; } else { cout << "The value " << key << " was found in position " << mid << endl; found = true; } } if (!found) { cout << "The value " << key << " was not found" << endl; } system("pause"); return 0; }// end of main