C++ program to enter the P, T, R, and calculate its Compound Interest
ADVERTISEMENTS
C++ program to enter the P, T, R, and calculate its Compound Interest. There are you will learn how to find the Compound Interest through P, T, R in the C++ language.
Formula:
CI = P * pow((1 + R / 100), T)
Where:
P = Principal Amount
T = Time
R = Rate
CI = Compound Interest
Let us understand this example through the C++ program:
// C++ program to enter P, T, R, and calculate Compound Interest
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float p, t, r, CI;
// p = principle
// t = time
// r = rate
// CI = compound interest
cout << "Enter the principal (amount), time, and rate::\n";
cin >> p >> t >> r;
/* Calculate compound interest */
CI = p * (pow((1 + r / 100), t));
// Output
cout << "\nCompound Interest = " << CI;
return 0;
}
Output:
Enter the principal (amount), time, and rate::
5
7
9
Compound Interest = 9.1402