# How to Write a program in c to convert decimal to binary

Decimal to binary conversion in c programming language. C source code for decimal to binary conversion:

**Algorithm:**

Binary number system: It is base 2 number system which uses the digits from 0 and 1.

**Decimal number system:**

It is base 10 number system which uses the digits from 0 to 9

Convert from decimal to binary algorithm:

Following steps describe how to convert decimal to binary

Step 1: Divide the original decimal number by 2

Step 2: Divide the quotient by 2

Step 3: Repeat the step 2 until we get quotient equal to zero.

Equivalent binary number would be remainders of each step in the reverse order.

Decimal to binary conversion with example:

For example we want to convert decimal number 25 in the binary.

* Step 1: *25 / 2 Remainder : 1 , Quotient : 12

*12 / 2 Remainder : 0 , Quotient : 6*

**Step 2:***6 / 2 Remainder : 0 , Quotient : 3*

**Step 3:***3 / 2 Remainder : 1 , Quotient : 1*

**Step 4:***1 / 2 Remainder : 1 , Quotient : 0*

**Step 5:**So equivalent binary number is: 11001

That is (25)10 = (11001)2

**Sample output:**