#include <iostream>
using namespace std;
int decTobinary(int decNum){
int ans=0,pow=1;
while(decNum>0){
int rem = decNum % 2;
decNum/=2;
ans+= (rem * pow);
pow *=10;
}
return ans;//binary form
}
int main() {
int decNum=50;
cout << decTobinary(decNum) << endl;
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: