In this tutorial you will learn about the c program to calculate compound interest and its application with practical example.
In this tutorial, we will learn to create a C program that will Calculate Compound Interest using C programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Arithmetic operators.
- Basic input/output
- C loop statements
- Operator precedence
- Data types.
What Is Compound Interest?
Compound interest (or compounding interest) is an interest to the principal sum of loan or deposit by consumer or by bank to consumer, or in other words,Compound Interest is interest on interest.
CI is interest earned from the original principal + accumulated interest.
formula for Compound Interest is.
Here,
P is principle amount.
R is the rate in Percent.
T is time in year.
C Program to Calculate Compound Interest.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#include <stdio.h> #include <math.h> int main() { float p, r, t, ci; // declaring varibales printf("Enter principle amount : "); // taking values from user scanf("%f", &p); printf("Enter time in year: "); scanf("%f", &t); printf("Enter rate in percent: "); scanf("%f", &r); ci = p* (pow((1 + r / 100),t)); // calculating ci printf("Compound Interest is = %f", ci); // printing CI return 0; } |