I'm quite new to C++, I'm trying to generate a random number between 1 and 10 (meaning 1 and 10 is excluded from the random number), but I'm having some difficulty achieving that. The following code produces a random number between 0 and 10, but I need the number 1 to be excluded, thus generating a random number consisting of 2 to 9, but I don't know how to do that. Thanks in advance.
The modulo operator (%) gives you the remainder after division.
This means that X % Y will always give you a number between [0,Y) (assuming X and Y are both > 0)
From there, you can just add values to your generated number to adjust it: