Java program to convert decimal to binary
Decimal number have base 10 and they ranges from 0 to 9.
Binary number have base 2 and they ranges from 0 to 1.
Following is the java program to convert decimal to binary.
Logic to convert decimal to binary in java
//always check name of class
public static void main(String agr)
int bin = new int;
Scanner in = new Scanner(System.in);
System.out.println("Enter any number : ");
int dnum = in.nextInt();
for(i = 0; dnum>0; i++)
bin[i] = dnum % 2;
dnum = dnum / 2;
for(int j=i-1; j>=0; j--)
Enter any number :
Connect with us on following platforms
PRACTICALS/PRACTICE PROGRAM IN Java
CHECKOUT OTHER RELATED TOPICS
We are aiming to explain all concepts of Java in easiest terms as possible.