My program transforms decimal numbers to binary representation. But I need it to transform it to 16 bit binary representation, mine only transforms to regular binary.

For example, Mine: 25 = 11001 but it should be 0000000000011001. This is my program:

#include <iostream>

using namespace std;

void dectobin(int num, int base);

int main()

{

int decimalnum;

int base;

base = 2;

cout<<"Enter the number in decimal: ";

cin>>decimalnum;

cout<<endl;

cout<<"Decimal: "<<decimalnum<<" = ";

dectobin(decimalnum, base);

cout<< " Binary" <<endl;

return 0;

}

void dectobin(int num, int base)

{

if(num > 0)

{

dectobin(num/base, base);

cout<<num % base;

}

}

What do I have to do to make it print out the remaining digits? Please Advise

void dectobin(int num, int base, int count = 0);

int main()

{

int decimalnum;

int base;

base = 2;

cout<<"Enter the number in decimal: ";

cin>>decimalnum;

cout<<endl;

cout<<"Decimal: "<<decimalnum<<" = ";

dectobin(decimalnum, base);

cout<< " Binary" <<endl;

cin >> base;

return 0;

}

void dectobin(int num, int base, int count)

{

if(num > 0 || count < 16)

{

dectobin(num/base, base, ++count);

cout<<num % base;

char c2[] = "0";

}

}

Regards, Alex