View Problem

Generate a random integer in a given range

Produce a random integer between 100 and 200 inclusive
DiskEdit
csharp
System.Random r = new System.Random();
int random = r.Next(100,201);
ExpandDiskEdit
erlang
RandomInt = gen_rand_integer(100, 200),
ExpandDiskEdit
cpp C++/CLI .NET 2.0
Random^ rnd = gcnew Random;
int rndInt = rnd->Next(100, 201);
ExpandDiskEdit
cpp
std::srand(std::time(NULL));

unsigned lb = 100, ub = 200;
unsigned rnd = lb + (rand() % ((ub - lb) + 1));
ExpandDiskEdit
cpp
typedef boost::uniform_int<> Distribution;
typedef boost::mt19937 RNG;

Distribution distribution(100, 200);
RNG rng; rng.seed(std::time(NULL));
boost::variate_generator<RNG&, Distribution> generator(rng, distribution);

unsigned rnd = generator();

Submit a new solution for csharp, erlang, or cpp
There are 16 other solutions in additional languages (clojure, fantom, fsharp, go ...)