Remove all occurrences of a digit from a number
Yes, the code can be simplified quite a bit, and in the process the static/global variable eliminated.

At least to me, an obvious implementation would be something like this:

unsigned rem(unsigned num, unsigned dig)
{
    if (num == 0)
        return num;

    unsigned digit = num % 10;

    unsigned temp = rem(num / 10, dig);

    if (digit != dig)
        temp = temp * 10 + digit;

    return temp;
}


So we basically split the number into the least significant digit, and everything else. We do the recursive call on the "everything else" part. Then we look at the least significant digit. If it's to be removed, we just leave it off the result. If it's not to be removed, we multiply the return value by 10, then add our digit on as the least significant again.

Of course, variations in syntax are possible. For example, you could use something like:

temp = rem(num / 10, dig);

return dig != digit ? temp * 10 + digit : temp;


That makes it shorter in terms of the number of lines of code, but it's essentially identical in terms of the real work being done.