OneCompiler

Write a program to read an integer from user and convert it to binary and octal using user defined functions.

128

object Demo6
{
def octal(num:Int) :Unit =
{
printf("Octal value : %o\n", num)
}
def main(args:Array[String])
{
print("Enter the Number = ")
var num = scala.io.StdIn.readInt()

		var binary = (num).toBinaryString
		
		println("Binary of "+num+" is "+binary)
		
		octal(num);
	}
}