
问题
编写一个C程序,计算存款金额在一些年后的增加利息
解决方案
计算利息的公式为 −
1 2 | M=((r/100) * t);
A=P* exp (M);
|
登录后复制
Where r= rate of interest
t=no. of years
P=amount to be deposited
M=temporary variable
A= Final amount after interest
算法
1 2 3 4 5 6 7 8 9 10 | 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
|
登录后复制
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # include <stdio.h>
# include <math.h>
# include <ctype.h>
int main(){
double P,r,t,A,M;
printf( "amount to be deposit in the bank: " );
scanf( "%lf" ,&P);
printf( "</p><p> enter the rate of interest:" );
scanf( "%lf" ,&r);
printf( "</p><p> How many years you want to deposit:" );
scanf( "%lf" ,&t);
M=((r/100) * t);
A=P* exp (M);
printf( "</p><p> amount after %0.1lf years with interest is:%0.2lf" ,t,A);
return 0;
}
|
登录后复制
输出
1 2 3 4 | 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
|
登录后复制
以上是C语言公式计算利息金额的详细内容。更多信息请关注PHP中文网其他相关文章!