Random numbers from -10 to 10 in C++
- by Chris_45
How does one make random numbers in the interval -10 to 10 in C++ ?
srand(int(time(0)));//seed
for(int i = 0; i < size; i++){
myArray[i] = 1 + rand() % 20 - 10;//this will give from -9 to 10
myArray2[i] =rand() % 20 - 10;//and this will -10 to 9
}