|
-
September 15th, 2012, 11:07 AM
#8
Re: Random numbers
 Originally Posted by en061
Means i should call srand outside the for loop?
Before the loop, yes. One way is to call it as near as possible to the beginning of the global main function.
 Originally Posted by en061
How do i avoid having the zeros in the random number?? I just need the number among 1 to 5.
With the current method that you are using, you can add 1 to the result to shift the range from [0, 4] to [1, 5].
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|