C program to convert decimal number to binary number.

source code


#include<stdio.h>
int main()
{
    long int decimalNumber,remainder,quotient;
    int binaryNumber[100],i=1,j;
    printf("Enter any decimal number: ");
    scanf("%ld",&decimalNumber);
    quotient = decimalNumber;
    while(quotient!=0)
{
  binaryNumber[i++]= quotient % 2;
  quotient = quotient / 2;
  }
          printf("Equivalent binary value of decimal number %d: ",decimalNumber);
          for(j = i -1 ;j> 0;j--)
         printf("%d",binaryNumber[j]);
    getch();
    return 0;
}

Comments

Popular posts from this blog

8086 STRING MANIPULATION –FIND AND REPLACE A WORD

Animated Circles In C++

C program to find out the sum of series 1 + 2 + …. + n.