Saturday, 18 November 2017

C++ Program to Generate Randomized Sequence of Given Range of Numbers


Code:

#include    iostream
#include    cstdlib
#include    time.h

const int LOW = 1;
const int HIGH = 32000;

using namespace std;

int main()
{
    int randomNumber;
    time_t seconds;
    time(&seconds);
    srand((unsigned int) seconds);
    for (int i = 0; i < 10; i++)
    {
        randomNumber = rand() % (HIGH - LOW + 1) + LOW;

        cout << randomNumber << " ";
    }
    cout << "...";
    return 0;
}


Output:

312 7423 23444 16008 31816 1823 29315 17424 11753 18384 ...



More C++ Programs:













100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...