用C语言公式计算利息金额
问题
编写一个C程序来计算几年后增加的存款金额和利息
解决方案
计算利息的公式是-
M=((r/100) * t); A=P*exp(M);
其中r=利率
t=否。年
P=存入金额
M=临时变量
A=利息后的最终金额
算法
START
Step 1: declare double variables
Step 2: read amount to be deposited
Step 3: read rate of interest
Step 4: read years you want to deposit
Step 5: Calculate final amount with interest
I. M=((r/100) * t);
II. A=P*exp(M);
Step 6: Print final amount
STOP示例
#include输出结果#include #include int main(){ double P,r,t,A,M; printf("存入银行的金额: "); scanf("%lf",&P); printf("\n enter the rate of interest:"); scanf("%lf",&r); printf("\n How many years you want to deposit:"); scanf("%lf",&t); M=((r/100) * t); A=P*exp(M); printf("\n amount after %0.1lf years with interest is:%0.2lf",t,A); return 0; }
存入银行的金额: 50000 enter the rate of interest:6.5 How many years you want to deposit:5 amount after 5.0 years with interest is:69201.53