# Binary to Decimal & Decimal to Binary in C++ / Python Using Some inbuild Functions.

## C++ :

1. Decimal to Binary
    
    ```cpp
    
    // return binary string with size 'b' which is binary representation of decimal number 'num'
    bitset<b>(num).to_string();
    
    Example : 
    
    // Binary String 't' of 65 with 32 bits 
    string t = bitset<32>(65).to_string();
    ```
    
2. Binary to Decimal
    
    ```cpp
    
    // Example : 
    // Convert 'binarystring' into decimal 
    string binarystring = "0100";
    int num = stoi(binarystring, 0, 2);
    ```
    

## Python :

1. Decimal to Binary
    
    ```python
    # Convert number 'a' into binary and store into 'a' itself
    a = bin(a)[2:]
    ```
    
2. Binary to Decimal
    
    ```python
    # Convert binary string 
    decimale = int(binarystring, 2)
    
    # Example 
    decimal = int("1010", 2)
    ```
