
C课后习题参考答案.docx
5页本文格式为Word版,下载可任意编辑C课后习题参考答案 习题参考答案 习 题 参 考 答 案 习 题 1 一、选择题 1、B 2、C 3、B 4、D 5、A 6、B 7、C 二、填空题 1、源程序文件 c 2、obj 3、可执行文件 exe 4、机器语言 汇编语言 高级语言 三、解答题 略 四、编程题 1、 main() { printf(“Hello! Welcome to China!”); } 2、 main() {int x; scanf(“%d”, if(x>=20 else printf(“Input error!”); } 习 题 2 一、选择题 1、C 2、A 3、B 4、D 5、 A 6、D 7、B 8、B 9、B 10、D 11、D 12、B 13、A 14、B 15、C 二、填空题 1、整型、实型、字符型 2、用户标识符、关键字标识符 3、存储单元、符号地址、内存地址 4、十、十六、八 5、double(双精度型) 6、 8 7、5.500000 8、a=-32768 295 习题参考答案 9、+0017,021,0x11 三、写程序运行结果 3257 32 57 7.88, -345.12,7.8765,-345.1230 7.87654e+00, -3.5e+02 a,97,141,61 1234,2322,4d2 CHINESE, CHI 四、scanf函数的使用 a=3 b=7 8.5 71.82 A a 五、用scanf函数输入数据 10 20Aa1.5-3.75 123.45,67.8 留神,其中123.45可以是任意实数,由于该值将被跳过,不用于赋值。
习 题 3 一、选择题 1. C 2. B 3. D 4. D 二、填空题 根本概念题 1. 2 2. 2 3. 1 阅读程序写出运行结果题 4. 1.00 5. 1,0,1 6. 9,11,9,10 三、写出下面表达式运算后a的值,设原来a=12 (1)24 (2)10 (3)60 (4)0 (5)0 (6)0 习 题 4 一、选择题 1、B 2、D 3、B 4、D 5、A 6、C 二、填空题 1、1,0,1 2、1,2,3 3、ch1>=′A′ 三、编程题 296 习题参考答案 1、从键盘输入三个数,然后按照由小到大的依次输出要求,设三个数放在变量a、b、中,结果依旧按照a、b、c的依次输出 #include main() {int a,b,c,t; scanf(“%d,%d,%d”, 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(“%d,%d,%d\\n”,a,b,c); } 2、编写程序根据以下的函数关系,对输入的x值输出相应的y值。
x y 2 main() {float x,y; scanf(“%f”, if(x main() {float a,b,c,d,disc,x1,x2,realpart,imagpart; scanf(“%f,%f,%f”, if(fabs(a)1e-6) {x1=(-b+sqrt(disc))/(2*a); x2=(-b-sqrt(disc))/(2*a); printf(“has distinct real roots:%8.4f and %8.4f\\n”,x1,x2); } else {realpart=-b/(2*a); imagpart=sqrt(-disc)/(2*a); printf(“has complex roots:\\n”); printf(“%8.4f+%8.4fi\\n”, realpart,imagpart); printf(“%8.4f-%8.4fi\\n”, realpart,imagpart); } } } 4、假设工资税率如下,其中s代表工资,r代表税率: s=3000) r=0.15; g=salary/500; switch(g) {case 1: r=0.05; case 2: case 3: r=0.08; case 4: case 5: r=0.10; } salary=salary*(1-r); printf(“%d\\n”,salary); 298 习题参考答案 习 题 5 一、选择题 1、A 2、C 3、C 4、D 5、A 6、A 7、A 8、B 9、C 10、B 11、B 12、D 二、填空题 1、continue 2、[1]n=0或x>=0.0 [2]x main() {int m,n,p,r,temp; printf(“Please input m,n:”); do {scanf(“%d%d”, }while(m main() {char c; int letter=0,space=0,digit=0,other=0; printf(“Please input a line character:”); while((c=getchar())!=’\\n’) {if(c>=’a’ else if(c==‘ ’) space++; else if(c>=’0’ else other++; } printf(“Letter is %d,Space is %d,Digit is %d,Other 299 — 5 —。






![河南新冠肺炎文件-豫建科[2020]63号+豫建科〔2019〕282号](http://img.jinchutou.com/static_www/Images/s.gif)





