Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To convert a C integer into a binary number, follow these steps:

  1. Write down the decimal number to be converted.

  2. Divide the decimal number by 2.

  3. Write down the quotient and the remainder.

  4. Divide the quotient by 2.

  5. Write down the new quotient and remainder.

  6. Repeat steps 4 and 5 until the quotient is 0.

  7. Write the remainders in reverse order to get the binary number.

For example, let's convert the decimal number 23 to binary:

23 / 2 = 11 remainder 1

11 / 2 = 5 remainder 1

5 / 2 = 2 remainder 1

2 / 2 = 1 remainder 0

1 / 2 = 0 remainder 1

The remainders in reverse order are: 10111

Therefore, the binary representation of 23 is 10111.