/*
Program to convert Decimal to Octal.
*/
import java.io.*;
class decimal2octal
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
decimal2octal call = new decimal2octal();
System.out.print("Enter a decimal number : ");
int n = Integer.parseInt(br.readLine());
System.out.print("\nOctal Equivalent : ");
call.dec2oct(n);
}
void dec2oct(int n)
{
int c;
if(n!=0)
{
c=n%8;
dec2oct(n/8);
System.out.print(c);
}
}
}
/**
* ALGORITHM :
* ---------
* 1. Start
* 2. Accept a decimal number from the user.
* 3. Using recursion, convert it to octal.
* 4. Print the Octal Equivalent.
* 5. End
*/
/*
OUTPUT :
------
Enter a decimal number : 25
Octal Equivalent : 31
*/
Program to convert Decimal to Octal.
*/
import java.io.*;
class decimal2octal
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
decimal2octal call = new decimal2octal();
System.out.print("Enter a decimal number : ");
int n = Integer.parseInt(br.readLine());
System.out.print("\nOctal Equivalent : ");
call.dec2oct(n);
}
void dec2oct(int n)
{
int c;
if(n!=0)
{
c=n%8;
dec2oct(n/8);
System.out.print(c);
}
}
}
/**
* ALGORITHM :
* ---------
* 1. Start
* 2. Accept a decimal number from the user.
* 3. Using recursion, convert it to octal.
* 4. Print the Octal Equivalent.
* 5. End
*/
/*
OUTPUT :
------
Enter a decimal number : 25
Octal Equivalent : 31
*/
This comment has been removed by a blog administrator.
ReplyDelete