We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc82c09 commit 0252572Copy full SHA for 0252572
.DS_Store
0 Bytes
Binary to Decimal.java
@@ -0,0 +1,19 @@
1
+#import java.util.*;
2
+class Binary_Decimal
3
+{
4
+ public static void main(String args[])
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%10;
13
+ s+=d*(int)Math.pow(2,c++);
14
+ k/=10;
15
+ }
16
+ System.out.println("Binary number:"+n);
17
+ System.out.println("Decimal equivalent:"+s);
18
19
+}
0 commit comments