19

Divide by 2 repeatedly and read the remainders from bottom to top. Example: 13 = 1101

Solution 1: Repeated division C++ 7 lines
int n = 13;
string bin = "";
while(n > 0){
    bin = char('0' + n % 2) + bin;
    n /= 2;
}
cout << bin; // 1101
Solution 2: bitset C++ 2 lines
#include <bitset>
cout << bitset<8>(13); // 00001101
Binary to Decimal C++ 5 lines
string b = "1101";
int dec = 0;
for(char c : b)
    dec = dec * 2 + (c - '0');
cout << dec; // 13