#include using namespace std; int search (int a[], int first, int last, int item) { while (first <= last) { int mid = (first+last)/2; if ( a[mid] == item) return mid; else if (a[mid] > item) last = mid -1; else first = mid + 1; } //end while return -1; }//end search void swap(int& x, int& y ) { int temp = x; x = y; y = temp; } void sort(int a[], int N) { bool sorted = false; while (!sorted) { N = N -1; sorted = true; for (int i =0; i < N; i++) if (a[i] > a[i+1] ) { swap(a[i], a[i+1]); sorted = false; }//endif }//end while }//sort int main() { const int N = 100; int a[N]; int item; srand(time(0)); //initialize the array with 100 random numbers for (int i = 0; i < N; i++) a[i] = rand()% 100; //sort the array sort(a, N); for (int i = 0; i < N; i++) cout << a[i]<<" "; cout <>item; int loc = search(a, 0, N-1, item); if (loc >= 0 ) cout << "Item found in location: " << loc <