Java Program to Convert Integer Values into Binary.
import java.util.Scanner;
public class Decimal_Binary
{
public static void main(String[] args)
{
int n, m;
String x = "";
Scanner s = new Scanner(System.in);
System.out.print("Enter the Decimal Number:");
n = s.nextInt();
while(n > 0)
{
int a = n % 2;
x = a + x;
n = n / 2;
}
System.out.println(x);
}
}
Post a Comment