I tried something like this

while (resultsBinary < SIZE) count++; cout << count << endl;

but it only counts in a sequential order for both.

Here is my full code without the above code.

#include <iostream> using namespace std; //Function prototype int searchList(int [], int, int); int binarySearch(int [], int, int); const int SIZE = 20; int main() { int numbers[SIZE] = {12, 13, 14, 15, 17, 21, 24, 25, 26, 29, 31, 36, 37, 38, 39, 45, 52, 75, 91, 95}; int resultsLinear; int resultsBinary; int numberHold; int count = 0; // Search for a number cout << "Enter a number you wish to search the array for: "; cin >> numberHold; { resultsLinear = searchList(numbers, SIZE, numberHold); if (resultsLinear == -1) cout << "The number you entered was not found." << endl; else { cout << " Your number, " << numberHold << " was in array field " << resultsLinear << ". " << endl; } } { resultsBinary = binarySearch(numbers, SIZE, numberHold); if (resultsBinary == -1) cout << "That number does not exist in this array. " << endl; else { cout << " That number is " << resultsBinary << " in the array." << endl; } system("Pause"); return 0; } system("Pause"); return 0; } // Linear Search Algorithm int searchList (int list[], int numElems, int value) { int index = 0; int position = -1; bool found = false; while (index < numElems && !found) { if (list[index] == value) { found = true; position = index; } index++; } return position; } // Binary Search Algorithm int binarySearch(int array[], int numElems, int value) { int first = 0, last = numElems - 1, middle, position = -1; bool found = false; while (!found && first <= last) { middle = (first + last) / 2; if (array[middle] == value) { found = true; position = middle; } else if (array[middle] > value) last = middle - 1; else first = middle + 1; } return position; }