Hello all,
I am trying to create a random number between a range of certain numbers, lets say 1 -10. I am using this below but for some reason it gives me the same number most of the time.
Code:
int rand_func(int min, int max )
//this function takes 2 arguments: min and max
// and creates random numbers based on min an max and loads it into i
{
int i = 0;
i = rand();
printf("\t%d", i);
i = min + (max - min) * i / RAND_MAX; // min and max forumula
printf("\t%d\n",i);
return i;
}
I appreciate any response. Thank You!