Print a decimal number as an unsigned binary number with N bits, e.g., print the number 11 (decimal) in binary using 5 bits.

Test whether each of the 5 bits should be 0 or 1, i.e., test the number to print against 10000, 01000, 00100, 00010, and 00001.

Is 11 >= 10000 (aka 16 or 2^4)? No, so first bit is 0.
Is 11 >= 01000 (aka 8 or 2^3)? Yes, so second bit is 1, and subtract 8 from the number.
Is 3 >= 00100 (aka 4 or 2^2)? No, so third bit is 0.
Is 3 >= 00010 (aka 2 or 2^1)? Yes, so fourth bit is 1, and subtract 2 from the number.
Is 1 >= 00001 (aka 1 or 2^0)? Yes, so fifth bit is 1, and subtract 1 from the number.

Note: each comparison is against a power of 2. You could use the pow standard library function, you could repeatedly multiple by 2, or you could take the number 1 and shift it left by (n-1) bits. For example, if the number of bits we want to use is 5, the number 10000 is 2^4, or 1 << 4.

An alternative way to see if a particular bit is on is to do a bit-wise and against the appropriate power of 2. In other words, if the second bit is on in a number X, then X & 01000 will be 01000, whereas if it is off, then X & 01000 will be 00000 (i.e., 0 or false).