I wish you had written the language which you are using...
I wrote it in C but you can easily integrate it on C++...
char ch;//input character
int ascii;//input's ascii equivalent
double sum = 0;//You can initilaize it to int but some compilers(like Dev-C++) causes troubles and generates wrong output...
printf("Enter any character ");
ascii = ch;//if you asssign a char to an int, the int variable holds the assigned character's ASCII code
for(i = 0;; i++)
b = ascii % 2;//converting binary...
ascii /= 2;//converting binary...
sum += b * pow(10,i);//variable b's first value is first digit the binary code from right to left
//so we multiply it by E+0
printf("%0.lf\n",sum);//Watch how your variable to be converted in ASCII
if(ascii == 1 || ascii == 0) break;//If we divide an integer to 2, we obtain 1 or 0 as a result
//if we don't control this will be an infinite loop.
sum += ascii * pow(10,i + 1);//End of our loop we divided the value 2 again and the variable ascii's value was 1
//so we exit the loop beacause of the if statement and we didn't multiply it E + 6.We are doing this here.