Whenever I try to run this code it returns numbers between 10 and 19 too but I intend return in the range between 20 and 30. I thought the pattern would be: %min+range but it seems useless although %50+50 turns back numbers between 50 and 99 but any other minimum does not work. Why?
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(0));
for(int i=1; i<100; i++)
{
cout<<rand()%20+10<<endl;
}
return 0;
}