Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; #include int* numbers(int num[]) { for (int i = 0; i < 6; i++) { num[i] = (rand() % 69

#include

#include

using namespace std;

#include

int* numbers(int num[]) {

for (int i = 0; i < 6; i++) {

num[i] = (rand() % 69 + 1);

}

sort(num, num + 6);

for (int i = 0; i < 6; i++) {

if (num[i] == num[i + 1]) {

num[i] = (rand() % 69 + 1);

}

}

sort(num, num + 6);

num[5] = (rand() % 26 + 1);

cout << endl;

return num;

}

int main()

{

srand(time(0));

int lottery[6];

int* p;

int n;

cout << "how many winning numbers would like to see? ";

cin >> n;

for(int i = 0; i < n; i++){

p = numbers(lottery);

cout << "Your winning numbers are: ";

for (int i = 0; i < 5; i++) {

cout << *(p + i) << " ";

}

cout << "your power ball is " << *(p + 5);

}

}

"Can you please explain this code step by step".

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

Students also viewed these Databases questions

Question

Describe your ideal working day.

Answered: 1 week ago