Decimal to Binary Number Program in Java

Decimal to Binary Number Program in Java
Decimal to Binary Number Program in Java

import java.util.Scanner;

/**
 *
 * @author AFAQ
 */
public class DecimalToBinary
{
    public static void main(String[] args)
    {
        int decimal;
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter decimal number=");
        decimal = sc.nextInt();
        
        String binary = "";
   
        while (decimal > 0) 
        {
            binary= decimal % 2 + binary ;
            decimal = decimal / 2;
        }
        
        System.out.println("Binary="+binary);
    }
}

Output:

Enter decimal number=13
Binary=1101
binary to decimal c program to convert decimal to binary convert decimal number to binary number convert decimal to binary in java decimal to binary decimal to binary conversion decimal to binary conversion in java decimal to binary in java decimal to binary java program decimal to binary program using java how to convert decimal to binary in java java program to convert decimal to binary learn java program to convert decimal numbers to binary numbers in c program to convert decimal to binary
Recent Posts