logo CodeStepByStep logo

printBinary

Language/Type: Java recursion

Write a recursive method named printBinary that accepts an integer and prints that number's representation in binary (base 2). For example, the call of printBinary(43); should print 101011 .

If the integer is negative, print the binary representation preceded by a minus sign. For example, the call of printBinary(-6); should print -110 .

Method: Write a Java method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.