Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write C PROGRAM * NOT C++ * that simulates a lottery. the program should have an

ID: 3566832 • Letter: W

Question

Write C PROGRAM * NOT C++ * that simulates a lottery. the program should have an array of five integers named winningdigits, with a randomly generated number in the range 0-9 for each element in array. the program should ask the user to enter 5 digits and should store them in a second arrray named player. the program must compare the corresponding elements in the two arrays and count how many digits match, once the user has entered a set of numbers the program should display the winning digits and the players digits and tell how many digits match. There can not be duplicate numbers in the array. Seperate into function calls rather than having one big main. If all 5 match, print "You are the winner".

Explanation / Answer

#include <iostream>

#include <cstdlib>

using namespace std;

int main()

{

const int LOT_NUMBERS = 5;

int Lottery[LOT_NUMBERS];

unsigned seed;

cout << "Please enter a seed value for the random numbers: ";

cin >> seed;

srand(seed);

for (int count = 0; count < LOT_NUMBERS; count++)

Lottery[count] = 0 + rand() % 9;

const int PICK_NUMBERS = 5;

int Pick[PICK_NUMBERS];

cout << "Please pick five numbers for the lottery. ";

for (int count = 0; count < PICK_NUMBERS; count++)

cin >> Pick[count];

cout << " The numbers picked were ";

for (int count = 0; count < PICK_NUMBERS; count++)

cout << " " << Pick[count];

cout << " The lottery numbers were ";

for (int count = 0; count < LOT_NUMBERS; count++)

cout << " " << Lottery[count];

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote