I cannot figure out why this error is happening: error: control may reach end of non-void function
Here is the code:
bool search(int value, int values[], int n) {
if (n < 1) {
return false;
}
for (int i = 0; i < n; i++) {
if (values[i] == value) {
return true;
break;
}
else {
return false;
}
}
}
I understand that the error means that the function may reach the end without returning anything, but I cannot figure out how that might happen.