title: Update iteration result
body: <p>EDIT: Global variables are restricted as part of the assignment (Forgot to mention this).</p>
  
  <p>The program is meant to calculate a projected population every year for a specified number of years. Here is the equation:</p>
  
  <pre><code>N = P(1 + B)(1 - D)
  </code></pre>
  
  <p>Where N is the new population size, P is the previous population size, B is the birth rate, and D is the death rate. B and D are decimals.</p>
  
  <p>So my problem is that I can only get the first iteration's result, and I don't know how to update the result so that it is multiplied by the (1 + B) and (1 - D). My guess is that it has to do with one of the combined assignment operators, but I haven't had success.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;cmath&gt;
  
  using namespace std;
  
  int get_pop();
  int get_numYears();
  double get_annBirthRate();
  double get_annDeathRate();
  double pop_new(int&amp; A, double&amp; B, double&amp; C, double&amp; D);
  
  int main()
  {
      int P,
      num,
      Y;
  
      double B,
      D,
      N;
  
      P = get_pop();
      B = get_annBirthRate();
      D = get_annDeathRate();
      Y = get_numYears();
      for (num = 1; num != Y; num++)
      {
          N = pop_new(P, B, D, N);
          cout &lt;&lt; "\n\nThe projected population for the end of year " &lt;&lt; num &lt;&lt; " is " &lt;&lt; N &lt;&lt; endl;
          cin.ignore();
      }
  
      return 0;
  }
  
  int get_pop()
  {
      int pop;
  
      cout &lt;&lt; "Enter the starting population:" &lt;&lt; endl;
      cin  &gt;&gt; pop;
      while (pop &lt; 2)
      {
          cout &lt;&lt; "\n\nError - starting population cannot be less than 2:" &lt;&lt; endl;
          cin  &gt;&gt; pop;
      }
      return pop;
  }
  
  
  double get_annBirthRate()
  {
      double annBirthRate;
  
      cout &lt;&lt; "\n\nEnter the annual birth rate \n(a positive percentage in decimal form):" &lt;&lt; endl;
      cin  &gt;&gt; annBirthRate;
      while (annBirthRate &lt; 0)
      {
          cout &lt;&lt; "\n\nError - annual birth rate cannot be negative:" &lt;&lt; endl;
          cin  &gt;&gt; annBirthRate;
      }
      return annBirthRate;
  }
  
  
  double get_annDeathRate()
  {
      double annDeathRate;
  
      cout &lt;&lt; "\n\nEnter the annual death rate \n(a positive percentage in decimal form):" &lt;&lt; endl;
      cin  &gt;&gt; annDeathRate;
      while (annDeathRate &lt; 0)
      {
          cout &lt;&lt; "\n\nError - death rate cannot be negative:" &lt;&lt; endl;
          cin  &gt;&gt; annDeathRate;
      }
      return annDeathRate;
  }
  
  
  int get_numYears()
  {
      int numYears;
  
      cout &lt;&lt; "\n\nEnter the number of years to display:" &lt;&lt; endl;
      cin  &gt;&gt; numYears;
      while (numYears &lt; 0)
      {
          cout &lt;&lt; "\n\nError - number of years cannot be less than 1:" &lt;&lt; endl;
          cin  &gt;&gt; numYears;
      }
      return numYears;
  }
  
  double pop_new(int&amp; P, double&amp; B, double&amp; D, double&amp; N)
  {
      N = P * (1 + B) * (1 - D);
  
      return N;
  }
  </code></pre>