Question
For this program, I keep getting a blank /****************************************************************************** Basic Template for our C++ Programs. *******************************************************************************/ #include /* printf, scanf, puts, NULL */ #include /*
For this program, I keep getting a blank /****************************************************************************** Basic Template for our C++ Programs. *******************************************************************************/ #include
int main() { int linearSearch(int[], int, int); int lotSize; const int Size = 5; int lotNumber[lotSize] = {45633, 78344, 34522, 66666, 90234}; int lotNumWinner; //holding the winner number int userInputLotNumber; cout << "Welcome to Lottery"; cout << " Enter your lottery number"; cin >> userInputLotNumber; //inputting for user lottery number lotNumWinner = linearSearch(lotNumber, lotSize, lotNumWinner); //if the winning number is found if (lotNumWinner == -1) cout << "You are the winner! "; else { //otherwise the user lost cout << "The lottery number don't match"; cout << "You lost the lottery"; } return 0; } int linearSearch(int array[], int lotsize, int value) { int index = 0; int position = -1; bool found = false; while (index < lotsize && !found) { if (array[index] == value) { found = true; position = index; } index++; } return position; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started