How to generate a random number from within a range - C?

All the answers so far are mathematically wrong. Returning rand() % N does not uniformly give a number in the range 0, N) unless N divides the length of the interval into which rand() returns (i.e. Is a power of 2).

Furthermore, one has no idea whether the moduli of rand() are independent: it's possible that they go 0, 1, 2, ... which is uniform but not very random. The only assumption it seems reasonable to make is that rand() puts out a Poisson distribution: any two nonoverlapping subintervals of the same size are equally likely and independent. For a finite set of values, this implies a uniform distribution and also ensures that the values of rand() are nicely scattered.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions