Question
#include #include #include #include using namespace std; #include int* numbers(int num[]) { for (int i = 0; i < 6; i++) { num[i] = (rand()
#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; string x; cout << "would like to play Y or N "; cin >> x; while(x != "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); } cout << endl << "would like to play Y or N "; cin >> x; } }
Explein every single step of this code and every single function.
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