7 Dec 2017

write a program in java to convert a decimal number to its equivalent Binary Digits.


class DecimalToBinary
{
          public static void main(String[] args)
          {
                   int num=13;
                   String bin="";
                   while(num>0)
                   {
                             bin=(num%2)+bin;
                             num=num/2;
                   }
                   System.out.println(Integer.parseInt(bin));
          }
}



Output