Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Calculate interest amount by using formula in C language
In C programming, calculating interest on deposited amounts is a common financial calculation. This program demonstrates how to compute the final amount after applying continuous compound interest over a specified period.
Syntax
A = P * exp((r/100) * t)
Where:
- P = Principal amount (initial deposit)
- r = Annual interest rate (percentage)
- t = Time period in years
- A = Final amount after interest
Algorithm
START
Step 1: Declare double variables P, r, t, A, M
Step 2: Read principal amount to be deposited
Step 3: Read annual interest rate
Step 4: Read number of years for deposit
Step 5: Calculate final amount using continuous compound interest
I. M = (r/100) * t
II. A = P * exp(M)
Step 6: Display the final amount
STOP
Example
The following program calculates the amount after applying continuous compound interest −
#include <stdio.h>
#include <math.h>
int main() {
double P, r, t, A, M;
printf("Amount to be deposited in the bank: ");
scanf("%lf", &P);
printf("Enter the rate of interest: ");
scanf("%lf", &r);
printf("How many years you want to deposit: ");
scanf("%lf", &t);
/* Calculate using continuous compound interest formula */
M = (r/100) * t;
A = P * exp(M);
printf("Amount after %.1lf years with interest is: %.2lf<br>", t, A);
return 0;
}
Output
Amount to be deposited in the bank: 50000 Enter the rate of interest: 6.5 How many years you want to deposit: 5 Amount after 5.0 years with interest is: 69201.53
Key Points
- This program uses the continuous compound interest formula with the exponential function
exp(). - The
math.hheader is required for theexp()function. - All variables are declared as
doublefor precise financial calculations.
Conclusion
This C program efficiently calculates compound interest using the exponential function. The continuous compounding formula provides accurate results for financial planning and investment calculations.
Advertisements
