Skip to content

Commit e0c07f4

Browse files
Merge pull request #16 from shivhek25/master
Added Decimal to Octal conversion.
2 parents 3816088 + 850b311 commit e0c07f4

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)