资源描述:
《c语言程序设计教程课后习题答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第1章1-3CAB4.c.obj.exe5/**/6;7算法8①中级语言:C语言具有高级语言的先进思想又能直接对存储器进行操作,能进行位运算,能实现汇编语言的大部分功能,生成目标代码质量高,程序执行效率高。②结构化语言:C语言用函数作为程序模块,以实现程序的模块化,语言简洁、紧凑,具有结构化的特点。③可移植性好:C语言不包含依赖硬件的输入输出机制,使C语言本身不依赖于硬件系统,可移植性好。9#includemain(){;}10#include“stdio.h”main(){printf(“ThisismyfirstCPro
2、gram!”);}第2章1.yes2.-33.2,14.1)a!=b
3、
4、a<=c2)x>=4
5、
6、x<=-45.x>20&&x<30
7、
8、x<-1006.#includemain(){intx;printf(“pleaseinputanintegar:”);scanf("%d",&x);if(x%5==0&&x%7==0)printf("yes");elseprintf("no");}7.#includemain(){intyear,month;printf("pleaseinputtheyearand
9、month:");scanf("%d%d",&year,&month);switch(month){case1:case3:case5:case7:case8:case10:case12:printf("thismonthhave31days.");break;case4:case6:case9:case11:printf("thismonthhave30days.");break;case2:if(year%4==0&&year%100!=0
10、
11、year%400==0){printf("thismonthhave29days.");brea
12、k;}else{printf("thismonthhave28days.");break;}}}8.#includemain(){floatmoney;intyear;printf("pleaseinputthemoneyandtheyear:");scanf("%f%d",&money,&year);if(year==1)money+=money*0.00315*12*year;if(year==2)money+=money*0.00330*12*year;if(year==3
13、
14、year==4)money+=mone
15、y*0.00345*12*year;if(year>=5&&year<=7)money+=money*0.00375*12*year;if(year>=8)money+=money*0.00420*12*year;printf("themoneyis:%f",money);}第3章1#include"stdio.h"main(){floatx[10],sum=0;inti=0;printf("pleaseinput10numbers(-10e616、+1/x[i];i=i+1;}printf("thesumof10numbersis%.2f",sum);}2#include"stdio.h"main(){intx[100],sum=0,aver,i=0;printf("pleaseinputnumbersuntil0");scanf("%d",&x[i]);while(x[i]!=0){sum=sum+x[i];i=i+1;scanf("%d",&x[i]);}printf("thesumis%d",sum);printf("theaverageis%.2f",float
17、(sum)/i);}3#include"stdio.h"#include"math.h"main(){inti=1,j,f;longints=0;while(i<=10){for(f=1,j=1;j<=i;j++)f=f*j;s=s+pow(-1,i-1)*f;i=i+1;}printf("s=%ld",s);}4#include"stdio.h"#include"math.h"main(){inti=0;floats=0.0;while(2*i+1<=101){s=s+pow(-1,i)/float(2*i+1);i=i+1;}prin
18、tf("s=%f",s);}5#include"stdio.h"#include"math.h"main(){inti,j,k,n=0;for(i=1;i<=9