trying to learn some basic data structures and algorithms and ive tried to code a basic binary search but it doesn't work unless the input is the same as the middle? can anyone help?
void Search(int input) {
int array[10] = { 0.1,2,3,4,5,6,7,8,9,10 };
int first = array[0];
int last = sizeof(array) / sizeof(array[0]);;
int middle = first + last / 2;
if (input == middle) {
cout << "search succesful";
}
else if (input > middle) {
middle + 1;
Search(input);
}
else if (input < middle) {
middle - 1;
Search(input);
}
}
int main()
{
int input;
cin >> input;
Search(input);
}
int array[10] = {0.1 ...that conversion is invalidmiddlevariable of the calling function is not the samemiddlevariable in the new call.