Convert a Given Decimal Number to Binary in Java

In this program, you'll learn to convert decimal number to a binary number using Array and Function in Java. This program takes a decimal number from console and it converts it into binary format . Input number is taken as Integer so convert it into an integer data using the while loop method. The Decimal number is divided by 2 and this reminder save in array .Print the binary number in reverse array using for loop

Decimal number to binary using Array:


When you run the program, the output will be:

Enter the Decimal Number : 15 
Binary is : 1111
Previous Post Next Post