title: How do I keep updating a variable's value?
body: <p>I was trying to write a code that will tell me the exponential growth using the unit amount of time (round) and population (pop) but ended up with a code that calculates value from the original variable. For example, when I input 10000 for pop and 3 for round, it should first calculate the the %5 of 10000, add it to original value, then calculate again with the new value for 2 more times. I cannot seem to find a way to update pop everytime the for loop is repeated. Can someone help me?</p>
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
      int pop, new_people;
      int i, round;
  
      cout &lt;&lt; &quot;Population: &quot;;
      cin &gt;&gt; pop;
      cout &lt;&lt; &quot;Round: &quot;;
      cin &gt;&gt; round;
  
      new_people = (pop * 5) / 100;
      
      for (i = 1; i &lt;= round; i++) {
          pop += new_people;
          cout &lt;&lt; pop;
      }
  
      return 0;
  }
  </code></pre>