title: Why this formula could not be calculated in c++?
body: <p>Here i want to calculate the number of sweets that i have been sold in Day 2.</p>
  <pre><code>int main()
  {
  float rate;
  int left, total, sell ;
  
  cout &lt;&lt; &quot;rate&quot; ; // the rate that sweets have been sold per day
  cin &gt;&gt; rate;
  cout &lt;&lt; &quot;sell&quot;; // number of sweets that have been sold in day1.
  cin &gt;&gt; sell;
  cout &lt;&lt; &quot;total&quot;; // total number that the shops originally have
  cin &gt;&gt; total;
  
  left = total - sell;
  
  sell = sell*(1+rate*(left/total));
          
  cout &lt;&lt; sell;
  return 0;
  }
  </code></pre>
  <p>And i want to calculate the numbers of sweets that have been sold in day2.
  Assume the input are rate = 0.5, sell=100, total = 10000.
  The output should be 14950. [ 10000 * (1+0.5*((10000-100)/10000)) ]
  But why I still get 10000 after running the program.</p>
  <p><code>Updated:</code></p>
  <p>However, I have one more question. If i want to output a rounded up <code>sell</code> value. How could I do it? because i am not allowed to change the datatype of the variables, which means it should be still <code>int sell;</code> at the initialization part. I have tried <code>cout &lt;&lt; round((double) sell);</code> But it still does not work.</p>