Why does the distribution of pseudorandom numbers change when operating like this?
rand() returns an integer uniformly distributed between 0 (inclusive) and RAND_MAX (exclusive).

When using modulo to partition those possibilities into 6 buckets you will end up with a few buckets that has 1 more possibility than the others. This means the random result ends up biased.

However the exact same thing happens if you use divide. The only difference lies in which buckets get biased.

This is due to pigeon stuffing. There is no way to divide a population of $2^n$ individuals into 6 groups perfectly evenly.

Instead you should check whether one of the biassing results is returned from rand() and generate a new number if so:

int bias = RAND_MAX % 6;
int divisor = (RAND_MAX - bias)/6;

while(true){
    int random = rand();
    if(random &lt; RAND_MAX - bias) 
        return random / divisor;
}


The difference between divide and modulo for partitioning the data has to do with which bits are more random. Many implementations of rand() use a simple linear congruential generator where the more significant bits have better randomness than the lesser significant bits. In a good RNG every bit is equally random and it does not matter whether you use modulo or divide.

Having said all that if you really cared about randomness you would use a proper high quality random number generator that doesn't have some of the well known issues you'll find in a LCG.