View Single Post
Join Date: Nov 2007
Posts: 390
Reputation: skatamatic will become famous soon enough skatamatic will become famous soon enough 
Solved Threads: 39
skatamatic skatamatic is offline Offline
Posting Whiz

Re: Generate 6 Random Numbers

 
0
  #3
Nov 14th, 2008
Why are you passing an array to displayLottery (in the declaration), it's not used in the method? Also, when you set the lottery you are only setting index # 6. And if you had properly passed your array from main it would be an out of range index (which will throw an exception).

Also, when you generate random numbers, use a mod (%) operator, not a * operator. I may be wrong, but I think it's possible for this to generate a int so big that it's bigger than an int's range. rand() % (MAX + 1) will generate a number between 0 and MAX, inclusive.
Last edited by skatamatic; Nov 14th, 2008 at 1:28 pm.
Reply With Quote