title: C++ Function is not returning a value
body: <p>here is my code, I can not figure out why it won't work as a function when  the exact code in main() produces the correct answer.  The assignment is to   convert binary number to decimal.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include "std_lib_facilities.h"
  using namespace std;
  int binaryCon(int biNum);
  int main()
  {
      int num, bin, Bnum;
      cout &lt;&lt; "Enter the binary number(1s and 0s) : ";
      cin &gt;&gt; num;
      bin = num;
      Bnum = binaryCon(num);
      cout &lt;&lt; "The decimal equivalent of " &lt;&lt; bin &lt;&lt; " : " &lt;&lt; Bnum &lt;&lt; endl;
  }
      int binaryCon(int biNum)
  {
      long dec = 0, rem = 0, base = 1;
      enter code here`while (biNum &gt; 0)
      rem = biNum % 10;
      dec = dec + rem * base;
      base = base * 2;
      biNum = biNum / 10;
  
      return biNum;
  }
  </code></pre>