Respuesta :

Answer:

#include <bits/stdc++.h>

using namespace std;

void LotheryPrinter(int number[])

{

   int a=1000;

   srand(time(0));//for generating different number on each program execution..

   while(a>50)

   {

       a=rand();//generating lottery number between 1 to 50...

   }

   cout<<a<<endl;//printing the lottery number..

   bool lottery=false;

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

   {

       if(number[i]==a)//finding that user has won the lottery or not..

       {

           cout<<"You have won the lottery"<<endl;

           lottery=true;

           break;

       }

   }

   if(!lottery)

   cout<<"Sorry try other time"<<endl;

}

int main() {

  int number[6];//array of integers of size 6..

  cout<<"Choose 6 numbers between 1 to 50"<<endl;

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

  cin>>number[i];

  LotheryPrinter(number);//calling the function..

return 0;

}

Output:-

Choose 6 numbers between 1 to 50

5 20 12 45 10 36

33

Sorry try other time

Explanation:

I have created a function called LotheryPrinter to generate a lottery number and and then matching the lottery number with the numbers entered by the user and all the number are between 1 to 50.

ACCESS MORE