Our social:

Decimal To Binary C Program

When we convert a Decimal Number we first divide the number and get the quotient 1 or 0. We divide the number till it becomes 0. Finally we get the binary number by writing the quotients backwards. This theory is applied to the following program.

c program


int main()
    int decimalNumber, quotient;
    int binaryNumber[100],i=1,j;

    printf("Enter any decimal number: ");

    quotient = decimalNumber;

        binaryNumber[i++]= quotient % 2;
        quotient = quotient / 2;

    printf("Equivalent binary value of decimal number %d: ",decimalNumber);
    for(j = i-1 ; j>0; j--)

    return 0;