Hi there

could someone explain

because I do not understand the term after modulus %.Code:rc= rand()%(max-min+1)+min;

I got this code from the homepage and was wondering how to use it with random double numbers.

example: min -1.0 max 1.0 . result -0.985, -0.750, 0.552...

any hint?

thx!

Code:#include<stdio.h> #include<stdlib.h> #include<time.h> int getrand(int, int); int main (void) { int i; int r; printf("\nrandom numbers\n"); for(i=0; i<20;i++) { r= getrand(-5.,5.); printf("your number is %d\n", r); } return 0; } int getrand(int min, int max) { static int Init=0; double rc; if (Init==0) { srand(time(NULL)); Init=1; } rc= rand()% (max-min+1)+min ; return (rc); }