convert "base 2 to base 10" c++ code example
Example: c++ base 10 to base 2
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";
}