c语言上机经典题目.docVIP

  • 27
  • 0
  • 约6.94千字
  • 约 12页
  • 2017-02-04 发布于北京
  • 举报
c语言上机经典题目

《C程序设计2》实验内容 实验一:循环控制(一) 1、编程计算 S=1*2+2*3+……+39*40 #include stdio.h main() { int a,b,S=0; for(a=1;a39;a++) {b=a+a+1;S=S+b;} printf(S=%d\n,S); getch(); } 2、编程计算 S==1!+2!+……+7! #include stdio.h main() { float n,s=0,t=1; for(n=1;n=7;n++) { t*=n; s+=t; } printf(1+2!+3!...+20!=%.0f\n,s); getch(); } 3、编写程序,计算如果每年按照年利率I(例如2%),投资S(例如5000),在第Y(例如10)年得到的总钱数M。公式:M=S*(1+I)Y #include stdio.h main() { float i,s,y,j,m,c=1; printf(please input I,S,Y:\n); scanf(%f,%f,%f,i,s,y); m=s; for(j=1;j=y;i++) {c=1+i; m=m*c;} printf(m=%f\n,m); getch(); } 4、编程输出九九乘法

文档评论(0)

1亿VIP精品文档

相关文档