#include<iostream>

#include<stdlib.h>

using namespace std;

class randomNum{

public:

int num,count,n,limit;

void printRandom()

{

cout<<"The random number series is "<<endl;

for(count=0;count<n;count++)

{

num = rand()%limit+1;

cout<<num<<" ";

}

}

};

int main()

{

randomNum obj1;

cout<<"Please enter how many random numbers you want\n";

cin>>obj1.n;

cout<<"Enter the upper range\n";

cin>>obj1.limit;

obj1.printRandom();

cout<<endl;

return 0;

}

#include<stdlib.h>

using namespace std;

class randomNum{

public:

int num,count,n,limit;

void printRandom()

{

cout<<"The random number series is "<<endl;

for(count=0;count<n;count++)

{

num = rand()%limit+1;

cout<<num<<" ";

}

}

};

int main()

{

randomNum obj1;

cout<<"Please enter how many random numbers you want\n";

cin>>obj1.n;

cout<<"Enter the upper range\n";

cin>>obj1.limit;

obj1.printRandom();

cout<<endl;

return 0;

}

Output 1:

Please enter how many random numbers you want

5

Enter the upper range

10

The random number series is

4 7 8 6 4

Output 2:

Please enter how many random numbers you want

5

Enter the upper range

100

The random number series is

84 87 78 16 94

Output 3:

Please enter how many random numbers you want

5

Enter the upper range

1000

The random number series is

384 887 778 916 794

## No comments:

## Post a Comment