C语言习题答案(人民邮电-第2版) (全)打印版C语言习题答案(人民邮电-第2版) (全)打印版.doc
文本预览下载声明
C语言习题答案
第1章
1.选择题
2.填空题
(1)main (2) main (3) 有穷性、确定性、有零个或多个输入、有一个或多个输出、有效性
(4) 顺序、分支和循环(5) 自顶向下,逐步细化、模块化设计、
第2章
1.选择题ACCDA DDBBA BBACB
2、填空题
(1) 数字、字母、下划线 (2)0 (3) 4、8 (4) (a+b)*c/(a-b) (5) -60 (6)-16
(7) (8)6、4、2 (9)0 (10)10、6 (11)12、4 (12)5.500000
(13) 0 (1)16 (1)6.6
3、编程题
#include stdio.h
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 stdio.h
#define RAT 1.60934
main()
{
float k;
printf(input the km:);
scanf(%f,k);
printf(mile:%f\n,k/RAT);
}
第3章
1.选择题(1) ~(10):DDCDDDCDCC
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=513a=513(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) CCAADCCABD
2.填空题
(4) ch=Ach=Z ch=ch-32
(5) x=10x2 x=2x-1 y=-1 ;
(6) a+bca+cbb+ca a==ba==c a==b||a==c||b==c
(7) x0 c=x/10 y!=-2
3.编程题
(1)
#include stdio.h
main()
{
int x;
printf(please input a number:);
scanf(%d,x);
if(x%2==0) printf(x is a even number);
else printf(x is a odd number);
}
(2)
#include stdio.h
main()
{
int x,y;
printf(please input a number:);
scanf(%d,x);
if(x-5 x0) { y=x; printf(%d,y); }
else if(x==0) { y=x-1; printf(%d,y); }
else if(x0 x10) { y=x+1; printf(%d,y); }
else printf(the number is error);
}
(3)
#include stdio.h
main()
{ int a,m;
printf(please input a number:);
scanf(%d,a);
switch(a/10)
{ case 0:
case 1:
case 2:m=1;break;
case 3:m=2;brea
显示全部