Q:

Write a C program to calculate Compound Interest

0

Write a C program to calculate Compound Interest.In this program , we  are going to calculate interest.So, the question arises  : 


What is compound interest?


It is the addition of interest to the principal sum of a loan or deposit, or in other words, interest on interest. It is the result of reinvesting interest, rather than paying it out, so that interest in the next period is then earned on the principal sum plus previously-accumulated interest.

It may be contrasted with simple interest, where interest is not added to the principal, so there is no compounding.


Annual compound interest formula

The formula for annual compound interest, including principal sum, is:

A = P (1 + r/n) (nt)

Where:

A = the future value of the investment/loan, including interest

P = the principal investment amount (the initial deposit or loan amount)
r = the annual interest rate (decimal)
n = the number of times that interest is compounded per year
t = the number of years the money is invested or borrowed for

Note that this formula gives you the future value of an investment or loan, which is compound interest plus the principal. Should you wish to calculate the compound interest only, you need this:

Total compounded interest = P (1 + r/n) (nt) – P

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

This program will read principal, rate and time in years and then print compound interest on entered principal for given time period.

Here,the below program is successfully compiled and run on the Windows System to produce output.Let’s check out the program below.


SOURCE CODE : :

#include <stdio.h>
#include <math.h>
 
int main()
{
    float principal, rate, year, ci;
     
    printf("Enter principal: ");
    scanf("%f", &principal);
     
    printf("Enter rate: ");
    scanf("%f", &rate);    
     
    printf("Enter time in years: ");
    scanf("%f", &year);
 
    //calculate comp. interest
 
    ci=principal*((pow((1+rate/100),year)-1));
     
    printf("Comp. interest is: %f\n",ci);
         
    return 0;
}

 

Output : :

Enter principal: 10000
    Enter rate: 10.25 
    Enter time in years: 5
    Comp. interest is: 6288.943359

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now