If i is an unsigned char (1 byte unsigned integer) then:
i = (i << 4) | (i >> 4);
If you know how to write inline assembly on your compiler (it differs between compilers), then rotating the byte is much more straightforward way to swap nibbles. In Intel assembly, it would look like:
ror i, 4
So in Microsoft compilers it would look like:
__asm
{
}