Ask Your Question
2

What is the process of converting a C integer into a binary number?

asked 2022-05-12 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-11-13 14:00:00 +0000

qstack gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-05-12 11:00:00 +0000

Seen: 8 times

Last updated: Nov 13 '21