#include <iostream>
#include <math.h>
using namespace std;

int main() {
    cout << "Enter Decimal Number : " ;
    int n;
    cin >> n;
    cout << endl;
    
    int res = 0, i = 0;
    while(n != 0){
        int bit = n & 1;
        res = (bit * pow(10, i)) + res;
        
        n = n >> 1;
        i++;
    }
    cout << "Binary is : " << res << endl;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: