/* The following small program demonstrates the use of random_range(). We initialise the pseudo random number generator using the current time, then set up a vector to store the results returned by random_range(). We provide storage for values from 0 to 11, but call random_range() with a range of 1 to 10. The function random_range() is called 10 times and output the random number */ #include #include using namespace std; int random_range(int lowest_number, int highest_number) { if(lowest_number > highest_number){ swap(lowest_number, highest_number); } int range = highest_number - lowest_number + 1; return lowest_number + int(range * (rand()/(RAND_MAX + 1.0))); } int main() { srand((unsigned)time(0)); int random_integer; for(int index=0; index < 10; index++) { random_integer = random_range(0,10); cout << random_integer <