>still gives the same error message
Is that all of the code in your program? If so, it's no surprise that the function isn't found as you don't define it. Your code should look something like this:
>And your return 0; is mistake also.
int GetRand(int min, int max);
int i, r;
for (i = 0; i < 20; i++)
r = GetRand(10, 12);
std::cout <<"Your number is " <<r <<std::endl;
int GetRand(int min, int max)
static int Init = 0;
if (Init == 0)
* As Init is static, it will remember it's value between
* function calls. We only want srand() run once, so this
* is a simple way to ensure that happens.
Init = 1;
* rand() % N <- To get a number between 0 - N-1
* Then add the result to min, giving you
* a random number between min - max.
rc = (std::rand() % (max - min + 1) + min);
No it isn't. You can enclose an expression with parentheses, they don't do anything in this case and are perfectly legal.