在本教程中,我们将讨论一个寻找复利的程序。
复利是通过将当前利息加到本金上,然后根据更新后的金额计算利息而得出的利息。
#include <bits/stdc++.h>
using namespace std;
int main(){
double principle = 10000, rate = 10.25, time = 5;
//计算复利
double CI = principle * (pow((1 + rate / 100), time));
cout << "Compound interest is " << CI;
return 0;
}输出结果
Compound interest is 16288.9