Write a java program to convert decimal to binary conversion

Write a Program that accepts a decimal number n, and converts the number to binary.

The return type is long representing the binary number.

Input and Output Format:
Input consists of the single integer.
The output consists of a single long.
Refer sample output for formatting specifications.

Sample Input 1:
Sample Output 1:

Convert decimal to binary conversion in Java.

import java.util.Scanner;

 public class Main {
                public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                String s1=Integer.toBinaryString(n);
                long y=Long.parseLong(s1);

You May Also Like These Posts:

Leave a Reply

Your email address will not be published.

10 − one =