[计算机类试卷]国家二级C语言机试(C语言程序设计)模拟试卷30及答案与解析.doc

上传人:boatfragile160 文档编号:497959 上传时间:2018-11-30 格式:DOC 页数:19 大小:52KB
下载 相关 举报
[计算机类试卷]国家二级C语言机试(C语言程序设计)模拟试卷30及答案与解析.doc_第1页
第1页 / 共19页
[计算机类试卷]国家二级C语言机试(C语言程序设计)模拟试卷30及答案与解析.doc_第2页
第2页 / 共19页
[计算机类试卷]国家二级C语言机试(C语言程序设计)模拟试卷30及答案与解析.doc_第3页
第3页 / 共19页
[计算机类试卷]国家二级C语言机试(C语言程序设计)模拟试卷30及答案与解析.doc_第4页
第4页 / 共19页
[计算机类试卷]国家二级C语言机试(C语言程序设计)模拟试卷30及答案与解析.doc_第5页
第5页 / 共19页
点击查看更多>>
资源描述

1、国家二级 C语言机试( C语言程序设计)模拟试卷 30及答案与解析 一、选择题 1 有以下程序 main()int a=3; doprintf(“ d, “, a-=2); while(!(-a); printf(“ n“); 程序运行后的输出结果是 ( A) 1, ( B) 1, -2, ( C) 3, 0, ( D) 1, 0 2 若 i和 k都是 int类型变量,有以下 for语句 for(i=0, k=-1; k=1; k+)printf(“* n“); 下面关于语句执行情况的叙述中正确的是 ( A)循环体执行两次 ( B)循环体执行一次 ( C)循环体一次也不能执行 ( D)构成无限

2、循环 3 若 k是 int类型变量,且有以下 for语句 1 for(k=-1; k main() int y=9; for(; y0; y-) if(y 3=0)printf(“ d“, -y); 程序的运行结果是 ( A) 963 ( B) 852 ( C) 741 ( D) 875421 6 有以下程序 #include main() int i, j, m=1; for(i=1: i0; j-) if(i*j3)break; m*=i*j; printf(“m= d n“, m); 程序运行后的输出结果是 ( A) m=2 ( B) m=4 ( C) m=5 ( D) m=6 7 有以

3、下程序 #include void main() int c=0, k; for(k=1; k main() int i, j; for(i=3; i=1; i-) for0=1; j1; i+) f*=i; ( D) f=1; for(i=n; i=2; i-) f*=i; 10 有以下程序 main() int i; for(i=1; i void main() char b, c; int i; b=a; c=A; for(i=0: i main() int i, j, m=55; for(i=1; i main()int x=8; for(; x0; x-) if(x 3)printf

4、(“ d, “, x-); continue; printf(“ d, “, -x); 程序的运行结果是 ( A) 8, 7, 5, 2, ( B) 9, 7, 6, 4, ( C) 7, 4, 2, ( D) 8, 5, 4, 2 24 以下叙述中正确的是 ( A) continue语句的作用是:使程序的执行流程跳出包含它的所有循环 ( B) break语句只能用在循环体内和 switch语句体内 ( C)在循环体内使用 break语 句和 continue语句的作用相同 ( D) break语句只能用于 switch语句体中 25 以下叙述中正确的是 ( A) break语句不能用于提前结

5、束 for语句的本层循环 ( B) continue语句使得整个循环终止 ( C)使用 break语句可以使流程跳出 switch语句体 ( D)在 for语句中, continue与 break的效果是一样的,可以互换 26 以下叙述中正确的是 ( A)当 break出现在循环体中的 switch语句体内时,其作用是跳出该 switch语句体,并中止循环体的执行 ( B)只能在循环体内和 switch语句体内使用 break语句 ( C) continue语句的作用是:在执行完本次循环体中剩余语句后,中止循环 ( D)在 while语句和 do-while语句中无法使用 continue语句

6、 国家二级 C语言机试( C语言程序设计)模拟试卷 30答案与解析 一、选择题 1 【正确答案】 B 【试题解析】 循环体执行两次。首先输出 a=1,然后判断表达式 !(-a), a为 0,循环条件表达式值为 1,执行第二次循环体,输出 a=-2。判断循环条件表达式值为0,循环退出。 【知识 模块】 C语言程序设计 2 【正确答案】 D 【试题解析】 本题考查 for循环。本题的 for循环初始条件为 i=0, k=-1;循环结束条件为 k=1永远为真 (k不为 0),因此循环不能结束。 【知识模块】 C语言程序设计 3 【正确答案】 B 【试题解析】 本题考查 for循环的使用。在程序中,

7、for循环的初始值 k=-1,循环结束条件是 k0”,循环全部结束。 【知识模块】 C语言程序设计 24 【正确答案】 B 【试题解析】 只能在循环 体内和 switch语句体内使用 break语句。 continue语句的作用是结束本次循环,即跳过本次循环体中 continue语句后面的语句,立刻进行下一次的循环条件判断,可以理解为仅结束本次循环。而 break语句可以使程序流程跳出 switch语句体,也可用 break语句在循环结构中终止循环体。 【知识模块】 C语言程序设计 25 【正确答案】 C 【试题解析】 用 break语句可以使程序流程跳出 switch语句体,也可用 brea

8、k语句在循环结构中终止循环体,从而提前结束循环,而 continue语句的作用是结束本次循环,即跳过本次循环体中 continue语句后面的语句,立刻进行下一次的循环条件判断,可以理解为仅结束本次循环。 【知识模块】 C语言程序设计 26 【正确答案】 B 【试题解析】 break语句可以使程序流程跳出 switch语句体,也可用 break语句在循环结构中终止循环体,从而提前结束循环,而当 break出现在循环体中的switch语句体内时,其作用只是跳出该 switch语句体,并不能中止循环体的执行。若想强行终止循环体的执行,可以在循环体中,但并不在 switch语句 中设置break语句,满足某种条件则跳出循环体。 continue语句的作用是结束本次循环。在 while和 do while循环中, continue语句使得流程直接跳到循环控制条件的测试部分,然后决定循环是否继续进行。 【知识模块】 C语言程序设计

展开阅读全文
相关资源
猜你喜欢
  • ANSI UL 60730-1-2016 UL Standard for Safety Automatic Electrical Controls C Part 1 General Requirements (Fifth Edition).pdf ANSI UL 60730-1-2016 UL Standard for Safety Automatic Electrical Controls C Part 1 General Requirements (Fifth Edition).pdf
  • ANSI UL 60730-2-10-2013 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Motor Starting Relays (Second Edition .pdf ANSI UL 60730-2-10-2013 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Motor Starting Relays (Second Edition .pdf
  • ANSI UL 60730-2-11-2013 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Energy Regulators (Second Edition Repr.pdf ANSI UL 60730-2-11-2013 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Energy Regulators (Second Edition Repr.pdf
  • ANSI UL 60730-2-12-2017 UL Standard for Safety Automatic Electrical Controls C Part 2-12 Particular Requirements for Electrically Operated Door Locks (Third Edition).pdf ANSI UL 60730-2-12-2017 UL Standard for Safety Automatic Electrical Controls C Part 2-12 Particular Requirements for Electrically Operated Door Locks (Third Edition).pdf
  • ANSI UL 60730-2-13-2014 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Humidity Sensing Controls (Second Edit.pdf ANSI UL 60730-2-13-2014 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Humidity Sensing Controls (Second Edit.pdf
  • ANSI UL 60730-2-14-2013 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Electric Actuators (Second Edition Rep.pdf ANSI UL 60730-2-14-2013 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Electric Actuators (Second Edition Rep.pdf
  • ANSI UL 60730-2-15-2014 UL STANDARD FOR SAFETY Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Automatic Electrical Air Flow Water Fl.pdf ANSI UL 60730-2-15-2014 UL STANDARD FOR SAFETY Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Automatic Electrical Air Flow Water Fl.pdf
  • ANSI UL 60730-2-2-2004 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Thermal Motor Protectors (Second Editio.pdf ANSI UL 60730-2-2-2004 UL Standard for Safety Automatic Electrical Controls for Household and Similar Use Part 2 Particular Requirements for Thermal Motor Protectors (Second Editio.pdf
  • ANSI UL 60730-2-22-2017 UL Standard for Safety for Automatic Electrical Controls C Part 2-22 Particular Requirements for Thermal Motor Protectors (First Edition).pdf ANSI UL 60730-2-22-2017 UL Standard for Safety for Automatic Electrical Controls C Part 2-22 Particular Requirements for Thermal Motor Protectors (First Edition).pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1