1. all numbers are stored in binary format.

2. octal and hexadecimal are powers of 2.

3. to get bit by bit of a number, u can use the 'right-shift'( >> ) operation in C.

4. to divide a number by 2^n, right shift the number by n bits.

so here is the procedure to get the binary/octal/hexadecimal representation of the number.

keep this string of bits/octets/hex-bits

char *nbits="0123456789abcdef";

1. to get the binary representation of the number..

right-shift bit by bit and keep storing/printing the bits one by one.

(for each shifted bit print---> nbits[value_of_shifted_bit

2. to get the octal representation of the number..

right-shift the number by 3-bits at a time, and each time checking the number in the thus got 3 shifted bits, and print the appropriate octet.

(for each shifted bit print---> nbits[value_of_shifted_bit

3. for hexadecimal, shift the bits 4 at a time

(for each shifted bit print---> nbits[value_of_shifted_bit

the number that u'll print this way will be in the right-to-left direction ( reversed from normal left-to-right)

try implementing code on this and we will help you out to make it work.

akshay