0

I'am trying to make a program that takes a number between 1 and 6.

I used this code: myvariable = rand()%7+1 ; but I always get an output of 2. so my question is how to make it take a random number?

16th Jun 2020, 9:04 AM
stef segers
1 Antwort
+ 1
I had the same problem once, I Google it and found out that you need a "seed" to create random numbers every time you run your code. I guess it's something like srand((unsigned) time(0)); But for something more accurate, look for it on the internet. Good Luck :)
16th Jun 2020, 9:16 AM
Alexandre
Alexandre - avatar