Что-то вроде ниже поможет вам.
double random(double start, double end)
{
double moduleValue = ((end - start) *10); //1.0 - .5 --> .5 -->> 5
double randum = rand() % moduleValue; // restrict the random to your range
//if rendum == 2 --> .2 + .5 --> .7 in the range .5 -- 1.0
return (randum / 10) + start; // make your number to be in your range
}
Тестовый код для уточнения
#include <stdio.h>
#define RAND_NUMBER 14
#define INT_FLAG 10
int main (int argc, const char * argv[]) {
// insert code here...
double start = .5;
double end = 1.0;
double moduleValue = ((end - start) * INT_FLAG);
int randum = (RAND_NUMBER / moduleValue);
double result = ((double)randum/INT_FLAG) + start;
printf("%f",result);
printf("Hello, World!\n");
return 0;
}