I want to print a random number in the range 1 to 6. I have the following code.
printf(\"The random value is %d \\n\",random(6));
It is pri
You shoud have srand() before rand() to generate new numbers each time. This code will show how do that:
srand()
rand()
# include # include # inlcude int main() { srand(time(0)); printf("The random value is %d\n", 1 + rand() % 6); return 0; }