Try something like this (obviously it will hit the overflow so you need to consider the overflow)
long long int decimal_binary(long int n)
{
long long int rem, i=1, binary=0;
while (n!=0)
{
rem=n%2;
n/=2;
binary+=rem*i;
i*=10;
}
return binary;
}
unsigned long long convert(unsigned long long int a)
{
if (a<1000)
{
return decimal_binary(a);
}
else
{
return ((convert(a/1000))<<10)+(convert(a%1000));
}
}