title: Type casting int into double C++
body: <p>I am new to programming and this might be an obvious question, though i cannot for life of me figure out why my program is not returning as a double.</p>
  
  <p>I am suppose to write a stocks program that takes in shares of stock, whole dollar portion of price and the fraction portion. And the fraction portion is to be inputted as two int values, and include a function definition with 3 int values.The function returns the price as a double. </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int price(int, int, int);
  
  int main()
  {
      int dollars, numerator, denominator, price1, shares;
      char ans;
      do
      {
          cout&lt;&lt;"Enter the stock price and the number of shares.\n";
          cout&lt;&lt;"Enter the price and integers: Dollars, numerator, denominator\n";
          cin&gt;&gt;dollars&gt;&gt;numerator&gt;&gt;denominator;
          cout&lt;&lt;"Enter the number of shares held\n";
          cin&gt;&gt;shares;
          cout&lt;&lt;shares;
          price1 = price(dollars,numerator,denominator);
          cout&lt;&lt;" shares of stock with market price of ";
          cout&lt;&lt; dollars &lt;&lt; " " &lt;&lt; numerator&lt;&lt;'/'&lt;&lt;denominator&lt;&lt;endl;
          cout&lt;&lt;"have a value of " &lt;&lt; shares * price1&lt;&lt;endl;
          cout&lt;&lt;"Enter either Y/y to continue";
          cin&gt;&gt;ans;
      }while (ans == 'Y' || ans == 'y');
      system("pause");
      return 0;
  }
  
  int price(int dollars, int numerator, int denominator)
  {
      return dollars + numerator/static_cast&lt;double&gt;(denominator);
  }
  </code></pre>