资源描述:
《c语言课后答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C语言习题答案第1章1.选择题(1)C(2)B(3)D2.填空题(1)main(2)main(3)有穷性、确定性、有零个或多个输入、有一个或多个输出、有效性(4)顺序、分支和循环(5)自顶向下,逐步细化、模块化设计、结构化编码第2章1.选择题BBCDADDBBABBDCB2、填空题(1)数字、字母、下划线(2)0(3)4、8(4)(a+b)*c/(a-b)(5)-60(6)-16(7)3(8)6、4、2(9)0(10)10、6(11)5.500000(12)12、4(13)double(14)0(15)16(16)6.63、编程题(1)main(){printf("in
2、t:%5d""float:%5d""char:%5d""double:%5d""long:%5d",sizeof(int),sizeof(float),sizeof(char),sizeof(double),sizeof(long));}(2)#defineRAT1.60934main(){floatk=0.0;printf("inputthekm:");scanf("%f",&k);printf("mile:%f",k*RAT);}第3章1.选择题(1)~(10):DDCDCDCDBC2.解析题(1)x=170,x=ㄩㄩㄩ170,x=ㄩㄩㄩ25
3、2,x=ㄩㄩㄩ170x=170,x=170ㄩㄩㄩ,x=ㄩㄩㄩ170,x=%6da=513.789185,a=ㄩㄩ513.79,a=513.78918457,a=513.78918457(2)a=3ㄩb=7x=8.5ㄩy=71.82c1=Aㄩc2=a3.编程题(1)main(){intx,y;scanf("%d%d",&x,&y);printf("商数=%d,余数=%d",x/y,x%y);system("pause");}(2)main(){doublex,y,z,avg;scanf("%lf%lf%lf",&x,&y,&z);avg=(x+y+z)/3;printf(
4、"%.1lf",avg,avg);system("pause");}第4章1.选择题(1)~(10)CCAADCCABD2.填空题(1)ch>='A'&&ch<='Z'ch=ch-32(2)x<=10&&x>2x<=2&&x>-1y=-1(3)a+b>c&&a+c>b&&b+c>aa==b&&a==ca==b
5、
6、a==c
7、
8、b==c(4)mark/10k=1case9(5)x<0c=x/10y!=-23.编程题(1)#includemain(){intx;printf("pleaseinputanumber:");scanf("%d",&x);if(x
9、%2==0)printf("xisaevennumber");elseprintf("xisaoddnumber");}(2)#includemain(){intx,y;printf("pleaseinputanumber£º");scanf("%d",&x);if(x<=-5)printf("thenumberiserror");elseif(x<0){y=x;printf("%d",y);}elseif(x==0){y=x-1;printf("%d",y);}elseif(x<10){y=x+1;printf("%d",y);}elseprintf
10、("thenumberiserror");}(3)#includemain(){inta,m;printf("pleaseinputanumber:");scanf("%d",&a);switch(a/10){case0:case1:case2:m=1;break;case3:m=2;break;case4:m=3;break;case5:m=4;break;default:m=5;break;}printf("%d",m);}(4)#includemain(){floatprice,tax;printf("pleaseinputth
11、epriceofproduct:");scanf("%f",&price);if(price>10000)tax=price*0.05;elseif(price>5000)tax=price*0.03;elseif(price>1000)tax=price*0.02;elsetax=0;printf("%f",tax);}(5)#includemain(){floatscore;printf("pleaseinputthescoreofstudent:");scanf("%f",&score);if(score>=85)