Hello everyone,
so i am basically new to C++ coding and i am trying to write the randNum function in a way that it will give me these ranges

The range for this row is: 1 to 10: 5 4 10 2 7 9 1 8 9 6
The range for this row is: 11 to 20: 20 15 16 11 20 11 13 13 13 11
The range for this row is: 21 to 30: 28 28 25 30 30 25 29 28 29 28
The range for this row is: 31 to 40: 39 33 34 40 37 40 31 37 37 31
The range for this row is: 41 to 50: 44 48 45 50 50 47 42 44 49 46
The range for this row is: 51 to 60: 55 59 55 51 60 56 57 60 53 56
The range for this row is: 61 to 70: 67 63 68 70 65 64 61 65 62 70
The range for this row is: 71 to 80: 77 76 79 72 77 79 80 78 72 78
The range for this row is: 81 to 90: 85 86 88 90 89 87 85 85 86 90
The range for this row is: 91 to 100: 100 95 92 98 94 96 93 95 92 95

this is what i've written so far and i got stuck, any help would be really appreciated.

#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;


int main() {

    srand(time(0));   // to get new random numbers for each run

    int first, last;
    first = 0;
    last = 9;
    for (int r = 1; r <= 100; r+=10) {
        cout<<"The range for this row is: "<<first+r<<" to "<<last+r<<": ";
        for(int c = 1; c <= 10; c++) {
            cout<<randNum(first+r,last+r)<<" ";
        }
        cout<<endl;
    }
    cout << endl;

    return 0;

}

any help anyone ?

Try using the random(int); function after calling randomize(); . Hope it works . random(n); generates any random number from 0 to n-1 .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.