



(36 votes)/* rand.cpp by detour@metalshell.com * * Generate a random number * * http://www.metalshell.com/ * */ #include <iostream> #include <cstdlib> #include <time.h> using namespace std; int main() { /* Initialize the random number generator with a seed */ srand((unsigned)time(NULL)); int rnda = int((double(rand())/RAND_MAX)*50); int rndb = int((double(rand())/RAND_MAX)*75) + 25; cout << "A number between 0 and 50: " << rnda << endl; cout << "A number between 25 and 100: " << rndb << endl; return 0; }