By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

Random number generator

P: 17
Can anyone plz suggest me an idea to generate pseudo random numbers ?
i tried using time function. can dis be done without using inbuilt functions?
Oct 2 '06 #1
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
Of course all you have to do is implement a pseudo random number generator algorithm much like the built in functions do.


Lots of information here
Oct 2 '06 #2

P: 17
Of course all you have to do is implement a pseudo random number generator algorithm much like the built in functions do.


Lots of information here
Thank you sir for the info.
Oct 3 '06 #3

P: 4
use this:

time_t seconds = time(NULL); //make sure this is declared at the beginning of the block
srand(seconds);
int a = rand();

If you want to generate the same set of random numbers again and again then seed srand with the same number instead of seconds - ideally pass this as a command line argument or a define at the top of your code.
Oct 3 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.