how would you write a for loop that calculates the total investment over 40 years if a one pays $500 each month but every 2 years the payment increases 10%?

//Begin loop: 0 to 40 (years)

     //Year_Total = Year_total + Monthly_payment * 12

     //If the Loop_Counter / 2 has no remainder, then it has to be a "2nd Year"
          //Monthly_payment = Monthly_payment * 1.10

//End Loop

how would you write a for loop that calculates the total investment over 40 years if a one pays $500 each month but every 2 years the payment increases 10%?

I wouldn't. Instead, I would post in a forum by disguising the question by asking the members in the forum, how would they write this. Actually, come to think of it, your statement above would suffice as a disguised question.

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  double investment = 0;
  double monthly_payment = 500;
  for (int k = 0;k < 20;k++)
  {
    for (int j = 0;j < 24;j++)
    {
      investment = investment + monthly_payment;
    }
    monthly_payment = 500*pow(1.1,k+1);
  }
  cout << investment << endl;
  return 0;
}