How to make random() only choose integers?

Is there a way? If not are there other codes that can do the trick?

Tagged:

Answers

  • edited May 2016 Answer ✓

    int rn = int (random (33));

    Will produce an integer in the range 0 to 32 inclusive.

  • Answer ✓

    Another way to phrase: int rnd = (int) random(100) is:
    Range of 0 (inclusive) and 100 (exclusive). In short: from 0 to 99. ;;)

Sign In or Register to comment.