Reversed Binary Numbers
Division and multiplication are relatively computationally costly operations compared to shifts and AND operations.  Try to reformulate your answer in terms of &gt;&gt; and &amp; and you will likely find a performance gain.

Other things I noticed that may help you improve your program:

Eliminate unused variables

Both len and str are unused and may be eliminated from the program.

Try to put the loop exit condition at the top of the loop

Instead of using do {...} while, prefer to use while {...} or a for loop.  in your case this will also neatly solve the problem that occurs when the user types in a negative number.

return 0 is not needed at the end of main

Any modern compiler will automatically assume that getting to the end of main means that the program has executed successfully and will generate the equivalent of return 0 at the end.  It is not necessary to write it.

Check the return value of scanf

The call to scanf can fail, in which case it will return 0.  Your code should check for that.

If your input says you will only have positive numbers, use unsigned

Instead of "%d" it would make more sense to say scanf("%u", &amp;n) since the inputs cannot be negative.  Note that this will not prevent negative numbers from being input, but it makes the expectation clear within the code.  Alternatively, check for negative number input to make the code more robust.

Consider verifying that your data type will hold the maximum value

The input specification says that the input numbers are all in the range of \$1 \le N \le 1,000,000,000\$ but an int isn't necessarily large enough on all platforms.  Since it takes 30 bits to express that number, and because it's unsigned, it would probably make more sense to use a uint_fast32_t type defined in &lt;stdint.h&gt; which is a fast integer type containing at least 32 bits.