I'm reviewing an example from an online course that I'm taking on basics for C++. The program takes in a loan balance and payment amount and calculates the amount of months it will take you to pay off your loan. I understand most of the program but I am having difficulties figuring out how exactly the program is calculating the months when there is no math formula calculating that (see while loop). Here is the code:
1 2 3 4 5 6
while(balance > 0)
{
months = months+1; //or months++
balance = balance - payment; //or balance = -=payment
}
cout <<"It will take you "<<months<<" months to pay off your loan."