Check out example codes for "c++ base 10 to base 2". It will help you in understanding the concepts better.

Code Example 1

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";
}

Learn ReactJs, React Native from akashmittal.com