Lottery Winners A lottery ticket buyer purchases 10 tickets a week, always playi
ID: 3629280 • Letter: L
Question
Lottery WinnersA lottery ticket buyer purchases 10 tickets a week, always playing the same 10 5-digit “lucky” combinations. I need to write a program that initializes an array or a vector with these numbers and then lets the player enter this week’s winning 5-digit number. The program should perform a linear search through the list of the player’s numbers and report whether or not one of the tickets is a winner this week. Here are the numbers:
13579 26791 26792 33445 55555
62483 77777 79422 85647 93121
Explanation / Answer
please rate - thanks
#include <iostream>
using namespace std;
int main()
{int numbers[10]={13579,26791,26792,33445,55555,
62483,77777,79422,85647,93121};
int i,win=-1, n;
cout<<"Enter the winning number: ";
cin>>n;
for(i=0;i<10;i++)
if(n==numbers[i])
{cout<<n<<" is a winner!!! :) ";
win=i;
}
if(win<0)
cout<<"Sorry you did not win ";
system("pause");
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.