I'm currently studying C language and I had a doubt in one of the program questions. The question is given below :

-----------------------------------------------------------PROBLEM

Write a program to calculate the Loan Balance, where a person borrows an amount A and in return he/she agrees to make N payments per year, each of amount P. While the person is repaying the loan, interest will accumulate at an annual percentage rate of R, and this interest will be compounded N times a year (along with each payment). Therefore, the person must continue paying these installments of amount P until the original amount and any accumulated interest is repaid.

NOTE: The formula to calculate the amount that the person needs to repay after T years is-

Balance Amount after T years = A[(1+R/N)^NT]-P

-----------------------------------------------------------

I have a few doubts :

1. I think that the "balance amount" formula can directly give the "loan balance" for the person. I'm not sure if it's correct but in that case the question would serve no purpose. Maybe I'm wrong.

2. If there should be a loop to calculate the loan balance, what condition should I give and which loop will be better to use?

It would be really grateful if anyone could help me with this problem. I'm a beginner so please forgive me if I say something stupid.

Thank you in advance for your help!