<stdlib.h>
int
main(void)
{
float
rate,capital,deposit=0
int
n
printf("Please
input
the
rate:")
scanf("%f",&rate)
printf("Please
input
the
n:")
scanf("%d",&n)
printf("Please
input
the
capital:")
scanf("%f",&capital)
deposit=capital+capital*n*rate/100
printf("The
deposit
is
%f
",deposit)
return
0
}
运行结果如下:
这里需要给你解释一下,输入的时候那个利率我是直接按百分比算的,比如2.25%
就输入2.25就好,计算的时候帮你转化成小数点了,如果要输入小数点那种,capital*n*rate/100这里的100你就自己去掉。
#includeint
main(void)
{
float
rate,capital,deposit=0
int
n
printf("Please
input
the
rate:")
scanf("%f",&rate)
printf("Please
input
the
n:")
scanf("%d",&n)
printf("Please
input
the
capital:")
scanf("%f",&capital)
deposit=capital+capital*n*rate/100
printf("The
deposit
is
%f\n",deposit)
return
0
}
运行结果如下:
这里需要给你解释一下,输入的时候那个利率我是直接按百分比算的,比如2.25%
就输入2.25就好,计算的时候帮你转化成小数点了,如果要输入小数点那种,capital*n*rate/100这里的100你就自己去掉。
#include <stdio.h>
int main()
{
double M = 0.00, R = 0.00, L, K// M本金,R为利率,L,K用来赋值交换保存数据
int qian = 0, i, Y = 0// Y为年,i用于循环 qian是本息
scanf("%lf%lf%d", &R, &M, &Y)
i = Y
L = M
while (i--)
{
K = M * (1.00 + R / 100)
M = K
}
qian = M
printf("%d", qian)
return 0
}