Program for Decimal to Binary Conversion | Function to return the binary equivalent of decimal value N ; To store the binary number ; Count used to store exponent value ; Driver code
function decimalToBinary ( N ) { var B_Number = 0 ; var cnt = 0 ; while ( N != 0 ) { var rem = N % 2 ; var c = Math . pow ( 10 , cnt ) ; B_Number += rem * c ; N = parseInt ( N / 2 ) ; cnt ++ ; } return B_Number ; } var N = 17 ; document . write ( decimalToBinary ( N ) ) ;