TheAlgorithms-C-Plus-Plus/Others/Decimal To Binary.cpp
2017-12-23 18:30:49 +01:00

21 lines
242 B
C++

#include<iostream>
using namespace std;
int main()
{
int number;
cin>>number;
int remainder,binary=0,var=1;
do{
remainder=number%2;
number=number/2;
binary=binary+(remainder*var);
var=var*10;
}
while(number>0);
cout<<binary;
}