Added Decimal to Octal conversion.

This commit is contained in:
Shivam Singhal 2017-03-28 19:21:53 +05:30
parent 025257206c
commit 850b31108e
2 changed files with 19 additions and 0 deletions

BIN
.DS_Store vendored

Binary file not shown.

19
Decimal to octal.java Normal file
View File

@ -0,0 +1,19 @@
#import java.util.*;
class Decimal_Octal
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,k,d,s=0,c=0;
n=sc.nextInt();
k=n;
while(k!=0)
{
d=k%8;
s+=d*(int)Math.pow(10,c++);
k/=8;
}
System.out.println("Decimal number:"+n);
System.out.println("Octal equivalent:"+s);
}
}