资源描述:
《C语言程序设计(张淑华、朱丽莉版)课后习题参考答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C语言程序设计(张淑华、朱丽莉主编)课后习题解答(仅供参考)习题一一、选择题1.B2.D3.B4.A5.B6.C7.C二、填空题1..obj2.函数3./**/4.#includeinta,b;a,b三、简答题(略)习题二一、选择题1.B2.B3.A4.D5.A6.C7.C8.A9.C10.B11.A12.A13.C14.A15.C二、填空题1.变量2.存储数据的单元3.非0、04.(1)a>=0(2)05.16.17.-308.389.4,710.-617777211.9.912.7三、写出下列程序的运行结果1.0,0,52.183.
2、6451284.55.d4,c四、编程题1.#include#definePI3.1415926voidmain(){floatr,s;printf(“Pleaseinputcircinalradii”);scanf(“%f”,&r);s=PI*r*r;printf(“r=%.2f,s=%.2f”,r,s);}2.#includevoidmain(){charc1,c2;printf(“Pleaseinputamajuscule”);scanf(“%c”,&c1);c2=c1>’A’&&c1<’Z’?c1+
3、32:c1;printf(“%c”,c2);}3.#includevoidmain(){inta=0,b;scanf(“%c”,&b);b=b&a;printf(“b=%d”,b);}习题三一、选择题1.C2.C3.A4.C5.D6.原题第2行应为c=(c-=a-5),(a=b,b+3);答案为B否则输出结果为5,0,57.D8.C9.A10.B二、填空题1.-50300、a=-50,b=300a=-50b=3002.102030、10,20,30、a=10,b=20,c=303.15、0、0三、写出下列程序的运行结果1.a=7
4、89.654321,a=789.65,a=789.65432100,a=789.6543212.b=15,b=17,b=f3.c=1,x=0,y=0,z=14.2120,205.在TC环境下为216,125在VC环境下为216,1806.a=A,b=d,c=F7.9,4,12,128.x=4.500000,y=4,x+y=8.500000四、编程题1.#includevoidmain(){printf("**********************************");printf("HAPPYNEWYEAR!");pr
5、intf("**********************************");}2.(1)#includevoidmain(){inta=5,b=8,c=10,m,max;m=a>b?a:b;max=c>m?c:m;printf(“max=%d”,max);}(2)#includevoidmain(){inta,b,c,m,max;scanf("%d,%d,%d",&a,&b,&c);max=a>b?a:(b>c?b:c);printf(“max=%d”,max);}习题四一、选择题1.D2.D3.
6、C4.A5.D6.A7.C8.C9.D10.B二、填空题1.6、5、52.(a%3==0
7、
8、a%7==0)3.(1)a>b(2)a=c;(3)a,b,c三、写出下列程序的运行结果1.42.643.a=7,b=44.46465.*#46四、编程题1.另见填空题3#includevoidmain(){floata,b,c,t;scanf("%f,%f,%f",&a,&b,&c);if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(b>c){t=b;b=c;c=t;}printf(“%.2f,%.2f,%
9、.2f”,a,b,c);}2.#includevoidmain(){inta,b;scanf("%d,%d",&a,&b);if(a%b==0)printf(“%disdivisibleby%d”,a,b);elseprintf(“%disnotdivisibleby%d”,a,b);}3.(1)#includevoidmain(){intx,y;scanf(“%d”,&x);if(x>-5&&x<0)y=x;printf("y=%d",y);elseif(x==0)y=x-1;printf("y=%d
10、",y);elseif(x>0&&x<10)y=x+1;printf("y=