The basic formula is MAX - MIN + MIN. So something like this would work:



int num_between_x_and_y = (rand() % (X - Y)) + Y;