码迷,mamicode.com
首页 > 其他好文 > 详细

计算利息,for使用范例

时间:2017-03-22 21:08:44      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:r++   use   main   system   ret   res   oid   for   rate   

/*利息计算程序,for使用范例*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
double amount;/*存款总额*/
double principal=1000.0;/*初始本金*/
double rate=0.05;/*年利率*/
int year;/*储蓄年份*/
printf("\nWelcome.\n"
"Calculate the compound interest\n\n");
for(year=1;year<=10;year++)
{
amount=principal*pow(1.0+rate,year);
printf("%4d%21.2f\n",year,amount);
}/*end for*/
system("PAUSE");
return 0;
} /*end main*/

计算利息,for使用范例

标签:r++   use   main   system   ret   res   oid   for   rate   

原文地址:http://www.cnblogs.com/hgr123456/p/6601889.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!