Hello again,
I have this program that works fine
but when I try to put the random number generator in its own function, it only returns the same number repeatedlyCode:#include<stdio.h> #include<time.h> int main(void) { srand(time(NULL)); int x,i; for(i=0;i<10;i++) { printf("%d: %d\n", i, rand()%100+1); } }
any ideas why?Code:/* returns a random number between 1 and the paramater */ #include<time.h> #include<stdio.h> int func_rand(int n) { srand(time(NULL)); /*rand prototype*/ return rand()%n+1; }