Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Home » Solved Programs » Find binary equivalent of any decimal number

C program to find binary equivalent of any decimal number

#include<stdio.h>
#include<conio.h>

int main()
 {
   int i,no,m,x;

   printf("\n Enter Aany Number : ");
   scanf("%d",&no);
   printf("\n The binary equivalent of %d : ",no);
   for(i=15;i>=0;i--)
   {
      m=1<<i;
      x=no&m;
      if(x==0)
          printf("0");
      else
          printf("1");
    }
return 0;
 }
 

Binary equivalent of 10

C program to find binary equivalent of any decimal number