Skip to content

Instantly share code, notes, and snippets.

@beakr
Created April 26, 2014 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beakr/11324520 to your computer and use it in GitHub Desktop.
Save beakr/11324520 to your computer and use it in GitHub Desktop.
Generate a random integer in a range with C++.
int main(...)
{
srand(time(NULL));
while (true) {
int nmin = 220;
int nmax = 550;
int x = nmin + (std::rand() % (nmax - nmin + 1));
printf("%i\n", x);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment