#include<iostream>
#include<cstdlib> //for using rand
#include<ctime> //to include time in seconds,
//every time the specific number is inputed it will give random numbers
void RandomGenerator(int lmt); //function declaration
usingnamespace std;
int main()
{
int limit;
cout<< "Enter a number that is equal or greater than two: \n"<<endl;
while(!(cin>>limit) || limit<2)
{
cout<< "Invalid number! It must be greater than 2. Please try again: \n"<<endl;
system("PAUSE");
system("CLS");
cin.clear();
cin.ignore(10000, '\n');
cout<< "Enter a number that is equal or greater than two: \n"<<endl;
}
cout<<endl;
cout<< "The random numbers between "<<limit<< " is: \n"<<endl;
RandomGenerator(limit); //function calling
cout<<endl;
return 0;
}
void RandomGenerator(int lmt) //function definition
{
srand(time(0));
for(int v=0; v<lmt; v++)
{
cout<< (rand()%lmt)<< " ";
}
}
Enter a number that is equal or greater than two:
5
1 4 1 3 3