Skip to content

Commit 850b311

Browse files
committed
Added Decimal to Octal conversion.
1 parent 0252572 commit 850b311

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Decimal to octal.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#import java.util.*;
2+
class Decimal_Octal
3+
{
4+
public static void main()
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
int n,k,d,s=0,c=0;
8+
n=sc.nextInt();
9+
k=n;
10+
while(k!=0)
11+
{
12+
d=k%8;
13+
s+=d*(int)Math.pow(10,c++);
14+
k/=8;
15+
}
16+
System.out.println("Decimal number:"+n);
17+
System.out.println("Octal equivalent:"+s);
18+
}
19+
}

0 commit comments

Comments
 (0)