Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C PROGRAMMING Write a program to simulate a pick-5 lottery game. Your program must generate and store 5 distinct random numbers between 1 and 9
C PROGRAMMING
Write a program to simulate a pick-5 lottery game.
Your program must generate and store 5 distinct random numbers between 1 and 9 (inclusive) in an array.
The program prompts the user for:
an integer random seed
five distinct integers between 1 and 9 (which are stored in another array)
The program then compares the two arrays to determine if they are identical.
If the two arrays are identical, then the user wins the game.
otherwise, the program outputs the number of matching digits and their position in the array.
For Example:
Enter an integer random seed: 45 To play the Pick-5 game, enter five integers bewteen 1 and 9 (inclusive): 1 2 3 4 5 You didn't match any numbers! The winning numbers are: 6, 3, 5, 1, 4 Enter an integer random seed: 45 To play the Pick-5 game, enter five integers bewteen 1 and 9 (inclusive): 6 3 1 2 3 You only matched 2 numbers. Your numbers matched the Pick-5 numbers at position(s): 0, 1 The winning numbers are: 6, 3, 5, 1, 4 Enter an integer random seed: 45 To play the Pick-5 game, enter five integers bewteen 1 and 9 (inclusive): 6 3 5 1 4 Congratulations!!! You WIN!!! The winning numbers are: 6, 3, 5, 1, 4
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