So far no one has posted the proper way to use rand() which is:
(double)rand() / (double)RAND_MAX
Using rand() % RAND_MAX is not recommended.
Also, rand()/RAND_MAX is integer division and returns 0
This will give you an integer >= min and < max:
(int)(min + ((double)rand() / (double)RAND_MAX * (max - min)));
-C