C语言习题答案(人民邮电-第2版)(全)打印版.doc
文本预览下载声明
PAGE
PAGE 12
C语言习题答案
第1章
1.选择题
12 345
CBABD
2.填空题
(1)main (2) main (3) 有穷性、确定性、有零个或多个输入、有一个或多个输出、有效性
(4) 顺序、分支和循环(5) 自顶向下,逐步细化、模块化设计、限制使用goto语句
第2章
1.选择题
12 345 67 890 12 34 5
ACCDA DDBBA BBACB
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)12、4 (12)5.500000
(13) 0 (14)16 (15)6.6
3、编程题
(1)编写一个程序求各种类型数据的存储长度。
#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.选择题
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=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) CCAAD CCABD
2.填空题
(1)①a0b0||a0c0||b0c0
②ab||ac
③a5||-a5
④(a=0)((int)a)!=a
⑤(a%b)!=0
(2)①!(x0) ②1 ③!(x=0x=5)
(3)3、2、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
显示全部