Random Number Generation

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    int i, upperLimit, userCount;
    
    cout << "This program creates random numbers\n";
    cout << "Enter the upper limit of all generated random numbers: ";
    cin >> upperLimit;
    cout << "Enter the count of all random numbers: ";
    cin >> userCount;
    cout << "Creating " << userCount << " random numbers from 1 to " << upperLimit << ".\n\n";
    
    
    srand(time_t(NULL));
    
    for(i = 1; i <= 500; i++)
    {
        cout << (1 +(rand() % 1000)) << setw(4);
        if (i % 10 == 0)
        {
            cout << "\n";
        }
    }
    
    return 0;
}

Hi,
> Write your question here.

I wonder what you mean? :-X
sorry. I am supposed to create a program that will randomly generate 500 random numbers. It will print 50 lines with 10 random numbers per line. My problem is I do not know how to use the user input with the number generation. The user inputs how many numbers to generate, and the max number. How can I put that in my code for the number generation?
Topic archived. No new replies allowed.