TheAlgorithms-C-Plus-Plus/Decimal To Binary.cpp
Ashwek Swamy 7989930107
Added Proper Indentation
Added proper indentation and using shorthand.
2018-10-23 18:01:24 +05:30

18 lines
290 B
C++

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