#include #include // rand & srand #include // time using namespace std; const int LENGTH = 5; // length of the array int main() { int numbers[LENGTH]; // test scores int i = 0; // loop variable int key = 0; // value being searched for bool found = false; // flag variable for finding the key value srand(1); // or srand(time(NULL)); for (i = 0; i < LENGTH; i++) { numbers[i] = rand() % 50 + 1; cout << numbers[i] << " "; } cout << "Enter a number that you'd like to search for: "; cin >> key; for (i = 0; i < LENGTH; i++) // linear search for key value { if (numbers[i] == key) { cout << "Found it in position " << i << endl; found = true; break; } } if (found == false) { cout << "You didn't find it " << endl; } return 0; }// end of main