I'd like to generate numbers between -30 and 30.
I already tried the solution in Generating random integer from a range and it gave me these results:
111875657664
151875657664
211875657664
-41875657664
-151875657664
171875657664
-201875657664
-131875657664
-301875657664
-271875657664
This is my function:
int Random::genRandom() {
int rnd;
rnd = (rand()%61)-30;
return rnd;
}
This is the main source file:
#include "Random.h"
#include <iostream>
using namespace std;
int main() {
Random random;
int randomas;
for(int i=0; i<10; i++) {
randomas = random.genRandom();
cout << randomas << "\n";
}
return 0;
}
What should I do?