Q:

How to get uniformally distributed random number?

I am trying to generate three random number inside a for loop:
for (i=0; i<100; i++)
{
  item1 = rand()/(double)RAND_MAX*100;
  item2 = rand()/(double)RAND_MAX*200;
  item3 = rand()/(double)RAND_MAX*300;
}

So my question is:
How to get equally spaced random number for each item1, 2 and 3
like item1 = 10,20,30,40,50 item2 = 40, 60, 80, item3 = 25,35,45, etc.

A:

You just want to round random numbers, or scale/project them after the generating.
This is... multiplication. Sample: (Live On Coliru)
#include <random>
#include <iostream>

int main()
{
    std::mt19937 engine(time(NULL));
    std::uniform_int_distribution<int> dist(0,10); // arbitrary range chosen

    for (int i=30; i>0; --i)
    {
        int random = dist(engine);
        std::cout << (random*10) << "\t" << (random*20) << "\t" << (random*10 + 15) << "\n";
    }
}

Output:
90  180 105
30  60  45
90  180 105
50  100 65
70  140 85
10  20  25
40  80  55
30  60  45
80  160 95
60  120 75
0   0   15
40  80  55
20  40  35
20  40  35
90  180 105
50  100 65
80  160 95
0   0   15
0   0   15
0   0   15
40  80  55
50  100 65
10  20  25
60  120 75
100 200 115
80  160 95
70  140 85
90  180 105
30  60  45
60  120 75

