In my program, I have to find two random values with certain conditions:
i
needs to be int range [2...n]
k
needs to be in range [i+2...n]
so I did this:
i = rand() % n + 2;
k = rand() % n + (i+2);
But it keeps giving me wrong values like
for n = 7
I get i = 4
and k = 11
or i = 3
and k = 8
How can I fix this?