# Decimal to equivalent Binary coderinme

#### Decimal to equivalent Binary coderinme

Decimal to equivalent Binary coderinme
To convert any given decimal number into it’s equivalent binary form, we use the factorization method. I just hope you remember the factorization method that we learned in our school days. Beginning with the process, at each step, we check the divisibility of the given decimal number by two (2) and keep on noting the remainder at every single step sideways. Finally, to get the equivalent binary form, we assemble all the remainders noted noted earlier, by writing the remainders in the reverse order. One thing in this program we we can cross check our answer. For this we start from the extreme right, in the increasing order of power of two (2).

Let’s write a program in C which converts the given decimal number into its equivalent binary form. It’s really very simple. No worries. Check it out.

``````#include<stdio.h>
int main()
{
int a[20], dec, i=0,j;
printf("\nEnter the decimal number: ");
scanf("%d",&dec);
j = dec;
while( dec > 0 )
{
a[i]=dec%2;
i++;
dec=dec/2;
}
printf("\nEntered Decimal No : %d\nConverted Binary number is : ",j);
for(j=i-1;j>=0;j--)
{
printf("%d",a[j]);
}
getch();
return 0;
}``````