
问题
编写一个C程序,计算存款金额在一些年后的增加利息
解决方案
计算利息的公式为 −
M=((r/100) * t); A=P*exp(M);
Where r= rate of interest
t=no. of years
立即学习“C语言免费学习笔记(深入)”;
MATLAB(矩阵实验室)是MATrix LABoratory的缩写,是一款由美国The MathWorks公司出品的商业数学软件。MATLAB是一种用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境。除了矩阵运算、绘制函数/数据图像等常用功能外,MATLAB还可以用来创建用户界面及与调用其它语言(包括C,C++和FORTRAN)编写的程序。MATLAB基础知识;命令窗口是用户与MATLAB进行交互作业的主要场所,用户输入的MATLAB交互命令均在命令窗口执行。 感兴趣的朋友可以
P=amount to be deposited
M=temporary variable
A= Final amount after interest
算法
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("amount to be deposit in the bank: "); scanf("%lf",&P); printf(" enter the rate of interest:"); scanf("%lf",&r); printf("
How many years you want to deposit:"); scanf("%lf",&t); M=((r/100) * t); A=P*exp(M); printf("
amount after %0.1lf years with interest is:%0.2lf",t,A); return 0; }
输出
amount to be deposit in the bank: 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










