Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8733285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:37:05+00:00 2026-06-13T09:37:05+00:00

I am trying to write a program in C to calculate the remaining loan

  • 0

I am trying to write a program in C to calculate the remaining loan balance after a given number of months, given the balance, monthly payment amount, and interest rate. (Each month, the balance increases by (balance * (interest rate/12)), and decreases by the payment amount.)

My code to calculate the balance for each month is as follows:

for (i = 1; i <= n; i++) {
    loanAmount += (loanAmount * (intRate/12));
    loanAmount -= monthlyPayment;
    printf("The balance after month %d is %.2f\n", i, loanAmount);
}

I put in some values (loanAmount = 1000, intRate = 12, monthlyPayment = 100, n = 3), and I expected the result to be 910.00 after month 1, 819.10 after month 2, and 727.29 after month 3. However, I got these results instead:

Enter the loan amount:
1000
Enter the interest rate:
12
Enter the monthly payment amount:
100
Enter the number of monthly payments:
3
The balance after month 1 is 1900.00
The balance after month 2 is 3700.00
The balance after month 1 is 7300.00

What am I doing wrong in my code? I thought my algorithm was correct.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:37:06+00:00Added an answer on June 13, 2026 at 9:37 am

    Your interest rate needs to be .12 as your are just multiplying by 1 at the moment, therefore adding 1000 to the balance and then subtracting the payment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a python program that calculates a histogram, given a
new to python here. I am trying to write a program that calculate the
I'm trying to write program calculating average of given numbers stored in an array.
I am trying to write a program to calculate postfix expressions, it includes both
I'm trying to write a simple program to calculate betweeness using brandes_betweenness_centrality from boostlib.
I am trying to write a Java program to calculate factorial of a large
I am trying write a program in python to calculate heart rate training zones
I am trying to write a program using opencv to calculate the distance from
I'm trying to write a program to calculate triangles. Can anyone give me a
I am trying to write a program which can calculate factorial from 1-9 by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.