Convert decimal to binary in C

后端 未结 16 752
攒了一身酷
攒了一身酷 2020-12-10 09:38

I am trying to convert a decimal to binary such as 192 to 11000000. I just need some simple code to do this but the code I have so far doesn\'t work:

void de         


        
16条回答
  •  天命终不由人
    2020-12-10 10:01

    Here is the Algorithm to convert Decimal to Binary number

    • Divide the input decimal number by 2 and store the remainder.
    • Store the quotient back to the input number variable.
    • Repeat this process till quotient becomes zero.
    • Equivalent binary number will be the remainders in above process in reverse order.

    You can check c program here http://www.techcrashcourse.com/2015/08/c-program-to-convert-decimal-number-binary.html

提交回复
热议问题