Use any one of the numerous pseudo-random generators. Some are better than others. George Marsaglia developed several good generators. The Mersenne Twister is the gold standard of generators, but it is overkill for many applications.
You ask for a "number" in the singular. If you just need one and the statistical properties are not important, you can do something really simple like: int x = (time() * getpid()) % N; Don On Thursday, October 10, 2013 5:51:42 AM UTC-4, atul007 wrote: > > Hello, > Given integer N , How to generate random number from 0 to N without > using rand() function. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.