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.
2 parents 7810850 + fcebc1e commit fe86e70Copy full SHA for fe86e70
CPP/Problems/Decimal to Binary/main.cpp
@@ -0,0 +1,20 @@
1
+#include<bits/stdc++.h>
2
+using namespace std;
3
+
4
5
+// Decimal to binary conversion
6
+ int main()
7
+ {
8
+ int n;
9
+ cin>>n;
10
+ int ans = 0;
11
+ int i = 0;
12
+ while(n != 0)
13
14
+ int bit = n&1;
15
+ ans = (bit * pow(10, i)) + ans;
16
+ n = n >> 1;
17
+ i++;
18
+ }
19
+ cout<<ans;
20
CPP/Problems/Decimal to Binary/main.exe
46.3 KB
0 commit comments