title: I am not sure why I am getting this output from my function
body: <p>My function is supposed to take the user input of dollars and optionally pennies and convert it into all cents result. But for some reason the number I am getting is bigger than what the math should be producing. This is my code.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  double NumberOfPennies(int dollars, int pennies = 0)
  {
      int totalPennies = 0;
      totalPennies = (dollars * 100) + pennies;
      cout &lt;&lt; totalPennies;
      return 0;
  }
  
  int main()
  {
      cout &lt;&lt; NumberOfPennies(5, 6) &lt;&lt; endl; // Should print 506
      cout &lt;&lt; NumberOfPennies(4) &lt;&lt; endl; // Should print 400
      return 0;
  }
  </code></pre>
  
  <p>The output from this is 5060 and 4000. I am confused because 5 times 100 plus 6 should produce 506 like what the comments indicate. I am not sure why 5 times 100 and adding 6 gives the result of 506. Mathmatically I can't see how I am wrong but perhaps there is a reason because of my code?</p>