if (results == -1)
cout << "The integer that you have entered does not exist within the array.\n";
else
{
// otherwise results contain the subscript of the specified
// integer within the array
cout << "That integer is found at element " << results;
cout << " in the array.\n";
}
return 0;
}
//**************************************************************
//
// Function Name: getIntegers
//
// Purpose: menu prompt for user to input values into the array
//
// Input parameters: int
//
// Output parameters: request user for ten integers
//
// Return Value: 0
//
//**************************************************************
void getIntegers ()
{
cout << "Please enter ten integers (whole numbers)\n";
//**************************************************************
//
// Function Name: binaryIntegers
//
// Purpose: use a binary search to figure out whether the
// integer entered is within the array
//
// Input parameters: integers [TEN_INTEGERS]
//
// Output parameters: an integer of integers [TEN_INTEGERS]
//
// Return Value: 0
//
//**************************************************************
int binaryIntegers (const int array [], int size, int value)
{
int first = 0, // first array element
last = size - 1, // last array element
middle, // midpoint of search
position = - 1; // position of search value
bool found = false; // Flag
while (!found && first <= last)
{
middle = (first + last) / 2; // calculate midpoint
if (array[middle] == value) // If value found at mid
{
found = true;
position = middle;
}
else if (array[middle] > value) // If value is in lower half
last = middle -1;
else
first = middle + 1; // If value is in upper half
}
return position;
}
For some reason Microsoft visual c++ 2010 express keeps saying error LNK2019: unresolved external symbol "int __cdec1 binaryIntegers(int * const, int)" (?binaryIntegers@@YAHQAHH@Z) referenced in function _main