Basic Lottery Question

Hello, i was asked to do a lottery program.
So far i only learnt IF/ELSE, Switch Case, For/While/Do While and now Random. Since this is on the Random papper my teacher gave me i'm guessing that it is a requirement.
Lottery here in my country works this way:
5 numbers are chosen between 1-50(where numbers are not repeated);
2 stars are chosen between 1-12(where numbers are not repeated);
Prizes are higher accordingly to how many numbers and stars were correct.
Last edited on
closed account (E0p9LyTq)
Using an array to store the numbers chosen by the user and the numbers selected by the lottery will make checking the numbers for matches real easy.

You can "promote" the stars to different numbers other than 1 - 50.
i understand that, but i cannot use what i have not yet learned, so i think that arrays are out of the question.
Is there a way for me to run the random code 5 times and each time it removes the numbers that was picked randomly before? This way they dont pick the same number again.
Last edited on
HDinis09 wrote:
i understand that, but i cannot use what i have not yet learned, so i think that arrays are out of the question.


I tell you what, @HDinis09, since you came to this site why don't you learn about arrays here:
http://www.cplusplus.com/doc/tutorial/arrays/
Then, when you've learnt about arrays they won't be out of the question anymore, will they?
I tell you what, @HDinis09, since you came to this site why don't you learn about arrays here:
http://www.cplusplus.com/doc/tutorial/arrays/
Then, when you've learnt about arrays they won't be out of the question anymore, will they?

I have already learnt about them both in that tutorial and 2 other youtube videos and it just works beautifully, but i can't use them in this case, since i cannot use what i have not learnt in class, that is the only thing really.
Does your assignment actually state that you can't use arrays?

You can choose to call your selections number1, number2, number3, number4, number5 if you choose, but I think the rest of us would use arrays or some other sort of container.
I mean it doesn't say it, but i once used functions i didn't learn and my teacher didn't count that exercise :(
Last edited on
Why don't you ASK your teacher whether a particular feature is legitimate or not? If you are going to class (which I hope) ... then ask him/her there. Alternatively, send him/her an email. Academic staff won't bite you. Promise!
You could create individual variables like num1, num2,...,star1, star2 to store the random numbers.
Topic archived. No new replies allowed.