Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 /* printf, scanf, puts, NULL */ #include /* srand, rand */ #include /* time */ #include // String managment funtions. #include // For input and output #include // For math functions. #include #include using namespace std; //////////////////////////////////////////////////////////////////////// // y = (rand()% (maxValue-minValue + 1)) + minValue /// //////////////////////////////////////////////////////////////////////// int userInputLotNumber; // Insert your code below this line:

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Systems Analysis And Design

Authors: Joseph Valacich, Joey George

8th Edition

0134204921, 978-0134204925

More Books

Students also viewed these Programming questions