(完整版)全国计算机等级考试二级教程--C语言程序设计课后习题答案

发布时间 : 星期三 文章(完整版)全国计算机等级考试二级教程--C语言程序设计课后习题答案更新完毕开始阅读

《全国计算机等级考试二级教程--C语言程序设计》课后习题答案

第一章 1.1 EXE 1.2 C OBJ EXE 1.3 顺序 选择 循环 第二章 一. 选择题

2.1 B 2.2 D 2.3 B 2.4 A 2.5 C 2.6 A 2.7 B 2.8 B 2.9 D 2.10 C 2.11 B 2.12 B 2.13 A 二. 填空题 2.14 11 12 2.15 4.2 4.2

2.16 { } 定义 执行语句 2.17 关键字 用户标识符 2.18 int float double 2.19 float a1=1; float a2=1; 2.20 存储单元 2.21 3.5

2.22 (a*b)/c a*b/c a/c*b 2.23 把常量10赋给变量s 2.24 位 1或0

2.25 8 127 0111111 -128 10000000 2.26 32767 -32768 1000000000000000 2.27 10 8 16 三. 上机改错题 2.28

#include \删除行尾的\

main(); / * main function * / 删除\后的\注释中的*要紧靠“/”,即应为“/*”和“*/” 函数开始处遗失了一个“{”

float r,s ; /*/*r is radius*/,/* s is area of circuilar*/*/ 注释符号不可嵌套使用 r = 5.0 ;

s = 3.14159 * r * r ;

printf(\行尾遗失了“;” 函数结束处遗失了一个“}” 2.29

#include \

main /* main function */ main后遗失了“()” {

float a,b,c,v; /*a,b,c are sides, v is volume of cube */ a=2.0; b=3.0; c=4.0 行尾遗失了“;”

v=a*b*c;

printf(\行尾遗失了“;” } 第三章 一. 选择题

3.1 C 3.2 C 3.3 D 3.4 C 3.5 D 3.6 B 3.7 C 3.8 D 3.9 A 3.10 B

3.11 C 3.12 D 3.13 D 3.14 A 3.15 C 3.16 C 3.17 C 3.18 无答案 3.19 C 3.20 B

二. 填空题

3.21 (1)-2002500(2)i=-200,j=2500 (3)i=-200 j=2500 3.22 12 0 0 3.23 一条语句 ; 3.24 ;

3.25 100,25.81,1.89234 100 25.81 1.89234 100 25.81 1.89234 3.26 x=127,x= 127,x= 177,x= 7f,x= 127 3.27 x=127,x=127 ,x=$127 ,x=$000127,x=d

3.28 a=513.789215,a= 513.79,a= 513.78921500,a= 513.78921500

三. 编程题和改错题 3.29 修改后的程序如下: main() {

double a,b,c,s,v; printf(\

scanf(\ s =a*b; v=a*b*c;

printf(\ printf(\ } 3.30 #include main() {

int a=560,b=60;

printf(\ } 3.31 #include main() {

int a,b; a=1500;b=350;

printf(\ printf(\ } 3.32 #include main() {

double a,b,c,ave;

printf (\ scanf (\ printf (\ } 3.33 #include void main() {

int a,b,c,t;

printf(\请依次输入整数a,b,c:\ scanf(\

printf(\你输入的值是: a=%d,b=%d,c=%d\\n\ t=b;b=a;a=c;c=t;

printf(\交换之后的值是:a=%d,b=%d,c=%d\\n\ } 第四章 一. 选择题

4.1 A 4.2 A 4.3 A 4.4 D 4.5 C 4.6 A 4.7 B 4.8 C 4.9 D 4.10 C 二. 填空题 4.11 非0 0

4.12 < > >= <=同级 == !=同级 4.13 ! && || 4.15 !

4.16 a == b || a < c x > 4 || x < -4 4.17 1

4.18 x <= 0 1 > 0 4.19 3 2 2 4.20 *#

三. 编程题 4.21 略 4.22

#include

/* 检查日期的合法性 */

int checkdate(int year, int month, int day) {

if(year < 1900 || year > 2005) {

printf(\输入的年份无效!\\n\ return 0; }

else if(month < 0 && month > 12) {

printf(\输入的月份无效!\\n\ return 0; }

else if(day <= 0 && day > 31) {

printf(\输入的日期无效!\\n\ return 0; } else {

switch(month) { case 4: case 6: case 9: case 11: if(day > 30) {

printf(\输入的日期无效!\\n\ return 0; } break; case 2:

if((year%4 == 0 && year0 != 0) || year@0 == 0) {

if(day > 29) {

printf(\输入的日期无效!\\n\ return 0; } } else

联系合同范文客服:xxxxx#qq.com(#替换为@)