Generates a random integer in a given range.
random is a macro which uses rand to return a random number between 0 and (num-1).