How to Convert Decimal to Binary Number – Java Code

Given a  decimal  number, Write a java program to convert decimal to binary number.

For example :

Input : 4 ,   Output : 100

Input : 5 ,    Output : 101

Input : 10 ,    Output : 1010

Decimal to Binary Number

Decimal to Binary Number

Java Program to Convert Decimal to Binary Number

In this coding example, we are going to write a java code which convert decimal number to binary number. Here is the list of things we have in this code.

i)   In this program, we have store the remainder in an array, when the number is divided by 2.

ii)  Then, In next step divide the number by 2.

iii) Repeat the above two steps until the number is greater than zero.

iv)  In last step, print the array in reverse order.

Java Program to Reverse Each Words of a String

 

Find Common Elements in Two Arrays

How to Convert Decimal to Binary Number : Video Tutorial

In this tutorial, I have explained how to convert a decimal to binary number.

Tagged , . Bookmark the permalink.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.