Saturday, February 14, 2015

Binary To String.java in pgm



BinaryToString.java

public class BinaryToString
{
    public static void main(String[] args)
{
        int N = Integer.parseInt(args[0]);
        String s = "";

        while (N > 0)
        {
            s = (N % 2) + s;
            N /= 2;
        }
        System.out.println(s);
   }
}

No comments:

Post a Comment