title: C++, code to write the binary form of an integer after the decimal point
body: <p>What I want is to take in an integer, and convert it to binary in a method as close to the method shown in the below code. However, I want to convert the number to binary as if it were after a decimal point. So if I got 625 as input then I would want it converted into 101.</p>
  
  <p>Given the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int decTobinary(int);
  
  int main(){
      cout &lt;&lt; "Enter a number = ";
      int num;
      cin &gt;&gt; num; 
      int answer = decTobinary(num);
      cout &lt;&lt; "answer: " &lt;&lt; answer &lt;&lt; endl"
      return 0;
  }
  int decTobinary(int x) {
      if (x==0)
      return 0;
      return 10 * decTobinary(x/2) + x % 2;
  }
  </code></pre>