Recent Posts

Responsive Ads Here

Wednesday, 30 September 2015

How to convert Decimal to Binary in Java method-1



Method-1 

package ensuretoday.blogspot.in;

import java.util.Scanner;

public class DecimalToBinary 
{

public static void main(String[] args)
       {
Scanner sc=new Scanner(System.in);
System.out.println("Enter a Decimal Number ");
int str=sc.nextInt();
String s=Integer.toBinaryString(str);
System.out.println(s);
sc.close();

}

}

Out put :-









No comments:

Post a Comment