C 语言习题答案 第1 章 1.选择题 (1) C (2) B (3) A 2.填空题 (1)main (2) main (3) 有穷性、确定性、有零个或多个输入、有一个或多个输出、有效性 (4) 顺序、分支和循环(5) 自顶向下,逐步细化、模块化设计、结构化编码 第2 章 1.选择题 12 345 6 7 890 1234 5 ACCDA DCABA BBDDB 2、填空题 (1) 数字、字母、下划线 (2)0 (3) 4、8 (4) (a+b)*c/(a-b) (5) -60 (6)-16 (7)9 (8)6、4、2 (9)0 (10)10、6 (11)5.500000 (12) 12、4 (13) 0 (14)16 (15)6.6 3、编程题 (1)编写一个程序求各种类型数据的存储长度。 #include main() { printf("int:%d byte\n",sizeof(int)); printf("short int:%d byte\n",sizeof(short int)); printf("long int:%d byte\n",sizeof(long int)); printf("float:%d byte\n",sizeof(float)); printf("double:%d byte\n",sizeof(double)); printf("long double:%d byte\n",sizeof(long double)); printf("char:%d byte\n",sizeof(char)); } (2) #include #define RAT 1.60934 main() { float k; printf("input the km:"); scanf("%f",&k); printf("mile:%f\n",k/RAT); } 第3 章 1.选择题 12 345 67 890 (1) ~(10):DDCDD DCDCC 2.解析题 (1) x=170,x=ㄩㄩㄩ170,x=ㄩㄩㄩ252,x=ㄩㄩㄩㄩaa,x=ㄩㄩㄩ170 x=170,x=170 ㄩㄩㄩ,x=ㄩㄩㄩ170,x=%6d a=513.789185,a=ㄩㄩ513.79,a=513.78918457,a=513.78918457 (2) a=3 ㄩb=7x=8.5 ㄩy=71.82c1=A ㄩc2=a 3.编程题 (1) main() { int x,y; scanf("%d%d",&x,&y); printf("商数=%d,余数=%d",x/y,x%y); } (2) main() { double x,y,z,avg; scanf("%lf%lf%lf",&x,&y,&z); avg=(x+y+z)/3; printf("%.1f",avg); } 第4 章 1.选择题 (1)~(10) CCAAD CCABD 2.填空题 (1)①a>0&&b>0||a>0&&c>0||b>0&&c>0 ②a5||-a>5 ④(a<=0)&&((int)a)!=a ⑤(a%b)!=0 (2)①!(x>0) ②1 ③!(x>=0&&x<=5) (3)3、2、2 (4) ch>='A'&&ch<='Z' ch=ch-32 (5) x<=10&&x>2 x<=2&&x>-1 y=-1 ; (6) a+b>c&&a+c>b&&b+c>a a==b&&a==c a==b||a==c||b==c (7) x<0 c=x/10 y!=-2 3.编程题 (1) #include main() { int x; printf("please input a number:"); ...