random number generator

this is a random number generator code but i want to know why the number 11 never show up

int main()
{


srand(time(0));
int random = rand()%11;
cout << random << endl;

return 0;
}
The % operator gives you the remainder of the division. If you divide by 11 the remainder will be in the range 0-10.
Hello akar1,

As I have often seen: int random = rand() % 11 + 1; or you could use "% 12" based on Peter87's response.

Hope that helps,

Andy
Topic archived. No new replies allowed.