/*

* Title - Decimal to Binary Converter - My Way

*

* Programmer - Aditya Gupta (@Techy15)

*

* */

/*The more general approach is to take remainders after dividing by 2, but this one is by comparison*/

/*Compiled with g++ on Zorin OS (Linux)*/

#include<iostream>

using namespace std;

long pow(int a, int power){

if(power==0) return 1;

else if(power==1) return a;

else return a*pow(a,power-1);

}

int main(){

int dec,bin=0,wtemp1,wtemp2,i=0;

cin>>dec; wtemp1=wtemp2=dec;

while(wtemp1>0){

while(wtemp1>=pow(2,i)){

i++;

}

bin+=pow(10,i-1);

wtemp1-=pow(2,i-1);

i=0;

}

cout<<bin;

return 0;

}

~

* Title - Decimal to Binary Converter - My Way

*

* Programmer - Aditya Gupta (@Techy15)

*

* */

/*The more general approach is to take remainders after dividing by 2, but this one is by comparison*/

/*Compiled with g++ on Zorin OS (Linux)*/

#include<iostream>

using namespace std;

long pow(int a, int power){

if(power==0) return 1;

else if(power==1) return a;

else return a*pow(a,power-1);

}

int main(){

int dec,bin=0,wtemp1,wtemp2,i=0;

cin>>dec; wtemp1=wtemp2=dec;

while(wtemp1>0){

while(wtemp1>=pow(2,i)){

i++;

}

bin+=pow(10,i-1);

wtemp1-=pow(2,i-1);

i=0;

}

cout<<bin;

return 0;

}

~