Binary search implementation in c++.
The program asks for a sorted array and a target element to search for.
If the array is not sorted, the program exits.
If the target element is found, its position is displayed.
If the element is not found on the first try, the user gets a second chance to enter another target.
Enter the number of elements: 5
Enter a sorted array of elements:
Position 1: 2
Position 2: 4
Position 3: 6
Position 4: 8
Position 5: 10
Enter the target element: 7
Element 7 not found. Please enter another target element. One try remaining.
6
Element 6 found at position: 3