I'm trying to generate 10 numbers between 56 and 34, however when I execute the 10 numbers generated are outside the range for some reason, I can't find the error. I tried with a different variable outside the "for" and it generates number inside the wanted range..
#include <iostream>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main ()
{
int x;
int counter;
int y;
srand(time(NULL));
y = rand()%3+1;
cout << "test--->" << y << endl;
for (counter=0; counter<10; counter++)
{
x = rand()%56+34;
cout << x << endl;
}
system("pause");
return 0;