MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/Problems/Decimal to Binary/main.cpp:6–20  ·  view source on GitHub ↗

Decimal to binary conversion

Source from the content-addressed store, hash-verified

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 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected