0

Random numbers from -20 to 20

#define LEFT -20 #define RIGHT 20 if we do some_variable=rand()%RIGHT+LEFT - we get random numbers from 0 to -20; but if i try to do soem_variable=rand%(2*RIGHT)+LEFT - i still dont get numbers from -20 to 20 interval. Pretty dumb question but i really forgot how to do this

10th Dec 2021, 4:39 PM
Artur
Artur - avatar
2 Respostas
+ 5
rand()%(Right- Left +1)+Left
10th Dec 2021, 6:47 PM
Oma Falk
Oma Falk - avatar
+ 1
Thank you!
11th Dec 2021, 9:19 AM
Artur
Artur - avatar