Easiest Decimal to binary Conversion

#include<iostream>
#include <fstream>
#include <string>
using namespace std;

int dectobin(int,int);

int main(){
int decimalnum,base=2;
cout <<"Enter no. in decimal "<<endl;
cin>>decimalnum;
dectobin(decimalnum,base);
cout <<"binary is as foloows "<<endl;




}
int dectobin(int decimalnum,int base){
if(decimalnum>0){
dectobin(decimalnum/base,base);// i can't understand this can anyone tell
cout <<decimalnum%base;

}


}



closed account (48bpfSEw)
http://stackoverflow.com/questions/2548282/decimal-to-binary-and-vice-versa
Topic archived. No new replies allowed.