Decimal to binary and binary to decimal convertor
Validate User Input:

Always check user input is what you expect. The user may enter a valid number, or they may enter a number too long to be stored in the given type, or they might enter "fifty-three".

The code should handle these cases, rather than crashing, entering an infinite loop (option 2) or producing incorrect output (option 1). These are bugs in your program that need to be fixed. Check the answers here for ideas.

One way to do this is to loop and re-request data until the user enters an expected value. This pattern can be applied to significantly improve the overall structure of your program, e.g.:

while (true)
{
    auto conversionType = ask_conversion_type();

    if (conversionType == ConversionType::BinaryToDecimal)
    {
        // ... ask user for binary input with another loop
    }
    else if (conversionType == ConversionType::DecimalToBinary)
    {
        // ... ask user for decimal input with another loop
    }
    else
    {
        // error...
    }

    // maybe we also need an exit option?
}




Testing

Write unit tests, so you can check that the various components of the code work. In the simplest case, this can be done by adding a little function like so:

void test(bool condition)
{
    if (condition)
        std::cout &lt;&lt; "pass" &lt;&lt; std::endl;
    else
        std::cout &lt;&lt; "FAIL" &lt;&lt; std::endl;
}


and then writing some tests at the start of main() to make sure you get the output you expect for each function:

test(decimal_to_binary(0) == std::vector&lt;ulli&gt;{ 0 });
test(decimal_to_binary(2) == std::vector&lt;ulli&gt;{ 1, 0 });
//test(decimal_to_binary(-5) == um??? );


This will also help with thinking about edge cases!



Types

If each number in the vector will only store 0 or 1, maybe it doesn't need to be a vector&lt;ulli&gt;...



Context

What is the purpose of this code? If it's an excercise doing a particular thing (i.e. you have a special definition of a "binary number" you must adhere to, or you have to write your own functions), then you need to share that with us, lest it all be "optimised" away.

For example, we could just use std::bitset:

#include &lt;bitset&gt;
...

case 1:
{
    std::cout &lt;&lt; "\nEnter Decimal number\n";
    unsigned long long num;
    std::cin &gt;&gt; num;
    // check input... then:
    std::bitset&lt;64&gt; bits(num);
    std::cout &lt;&lt; "The binary equivalent of " &lt;&lt; num &lt;&lt; " is :\n" &lt;&lt; bits &lt;&lt; "\n";
    break;
}
case 2:
{
    std::cout &lt;&lt; "\nEnter Binary number\n";
    std::bitset&lt;64&gt; bits;
    std::cin &gt;&gt; bits;
    // check input... then:
    std::cout &lt;&lt; "The decimal equivalent of " &lt;&lt; bits &lt;&lt; " is :\n" &lt;&lt; bits.to_ullong() &lt;&lt; "\n";
    break;
}


The code is certainly shorter! But maybe doesn't fulfill some other requirements?