/* testRandom.cpp CIS 150 6/2/2005 David Klick This program demonstrates how random integers can be generated. Depending on the compiler, you may have to include cstdlib and ctime. */ #include using std::cout; int main(void) { int low = 10, high = 15; int num; // calculate range of numbers desired int range = high - low + 1; // seed random number generator srand(time(NULL)); // generate and display 10 random numbers // within desired range num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; num = rand() % range + low; cout << num << '\n'; return 0; }