C程序 复利
什么是 “复利”?
复利 是指在贷款或存款的本金上增加利息,或者换句话说,是利息的利息。它是将利息再投资,而不是支付利息的结果,因此下一期的利息是在本金加上以前积累的利息上获得的。复利是金融和经济学的标准。
复利可以与单利对比,单利是指利息不加在本金上,所以没有复利。
复利公式。
计算年复利的公式为:
**数量= P(1+R/100) t **
复利=金额-P
其中,
P是本金数额
R是比率
T是时间跨度
伪代码
Input principal amount. Store it in some variable say principal.
Input time in some variable say time.
Input rate in some variable say rate.
Calculate Amount using formula,
Amount = principal * (1 + rate / 100) time).
Calculate Compound Interest using Formula.
Finally, print the resultant value of CI.
示例:
Input: Principal (amount): 1200
Time: 2
Rate: 5.4
Output: Compound Interest = 133.099243
// C program to calculate Compound Interest
#include <stdio.h>
// For using pow function we must
// include math.h
#include<math.h>
// Driver code
int main()
{
// Principal amount
double principal = 10000;
// Annual rate of interest
double rate = 5;
// Time
double time = 2;
// Calculating compound Interest
double Amount = principal *
((pow((1 + rate / 100),
time)));
double CI = Amount - principal;
printf("Compound Interest is : %lf",CI);
return 0;
}
输出:
Compound interest is 1025