Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

LO5 Highlight five external recruiting sources.

Answered: 1 week ago