C Program for the compound interest?


Compound interest is the simple interest that is compounded annually i.e. the interest will be calculated and added to the principal amount every year. This increases the overall interest as compared to simple interest. There is a different mathematical formula to calculate the compound interest. Lets see with the an example,

Input:p=5, r=4, t=5
Output:1.083263

Explanation

Compound Interest = Principle * (1 + Rate / 100)^time
CI=5*(1+4/100)^5
CI=1.083263

Example

#include <iostream>
#include <math.h>
using namespace std;
int main() {
   float p, r, t, ci;
   p=5;
   r=4;
   t=5;
   ci = p * pow((1 + r / 100), t) - p;
   printf("%f", ci);
   return 0;
}

Updated on: 19-Aug-2019

182 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements