Question: Using C++ with functions 6. Lottery Write a program that simulates a lottery. The program should have an array of 5 integers named winningDigits, with

Using C++ with functions

Using C++ with functions 6. Lottery Write a program that simulates a

6. Lottery Write a program that simulates a lottery. The program should have an array of 5 integers named winningDigits, with a randomly generated number in the range of 0 through 9 for each element in the array. The program should ask the user to enter 5 digits and should store them in a second integer array named player. The program must compare the corresponding elements in the two arrays and count how many digits match. For example, the following shows the winningDigits array and the player array with sample numbers stored in each. There are two matching digits, elements index 2 and index 4. WinningDigits: 7 4 913 Player digits: 42973 Matching elements: 24 Numbers appearing in both arrays: 3497 To make sure your code works, display the contents of the winningDigits array before asking the user to enter their numbers Note: Both the winningDigits and the player arrays may not have duplicate numbers Enhance the program to print the numbers that appeared in both arrays. In our example, order not important: You may not use global variables, except for MAX_SIZE-5. Suggested functions void randomArray(int arr1, int &elements1): fills arr with random numbers. void playerArray(int arr20, int &elements2): fills arr2 with user entered numbers. bool isAlreadyln(int arr1.int elements, int n): returns true if n is already in arr1. void displayArray( (int arr1], int n): prints the elements of the array void showMatchinglint arr1, int arr2]): displayes the index/s of matching elements. There may not be any matching elements void numbersinBoth(int arr1 int arr20): displayes the numbers that appear in both arrays

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!