c++ base 10 to base 2

C++
void show_binary( int dec )
{
    std::cout << "decimal = " << dec << "\n";
    
    std::string bin{};
    
    while( dec > 0 ) {
        if( dec % 2 == 0 ) bin.insert( bin.begin( ), '0' );
        else bin.insert( bin.begin( ), '1' );
        
        dec >>= 1;
    }
    
    std::cout << "binary = " << bin << "\n";
}
Source

Also in C++: