《C语言循环结构练习题带答案(最新整理)》由会员分享,可在线阅读,更多相关《C语言循环结构练习题带答案(最新整理)(10页珍藏版)》请在人人文库网上搜索。
1、第 5 章循环结构程序设计练习题1. 单项选择题(1) 语句 while (!e);中的条件!e 等价于A。A. e=0B. e!=1C. e!=0D. e(2) 下面有关 for 循环的正确描述是D。A. for 循环只能用于循环次数已经确定的情况B. for 循环是先执行循环体语句,后判定表达式C. 在 for 循环中,不能用 break 语句跳出循环体D. for 循环体语句中,可以包含多条语句,但要用花括号括起来(3)C 语言中D。A. 不能使用 do-while 语句构成的循环B. do-while 语句构成的循环必须用 break 语句才能退出C. do-while 语句构成的循环。
2、,当 while 语句中的表达式值为非零时结束循环D. do-while 语句构成的循环,当 while 语句中的表达式值为零时结束循环(4)C 语言中 while 和 do-while 循环的主要区别是A。A. do-while 的循环体至少无条件执行一次B. while 的循环控制条件比 do-while 的循环控制条件严格C. do-while 允许从外部转到循环体内D. do-while 的循环体不能是复合语句(5) 以下程序段C。第 5 章 循环结构程序设计41int x=-1; dox=x*x;while (!x);A. 是死循环B. 循环执行二次C. 循环执行一次D. 有语法错误。
3、(6) 下列语句段中不是死循环的是 C 。A. i=100;while (1)i=i%100+1;if (i=20) break;B. for (i=1;i+)sum=sum+1;C. k=0; do+k; while (k main()int i;for (i=4;i main()int num=0;while (num main()int s=0,k;for (k=7;k=0;k-)switch(k)case 1:case 4:case 7: s+; break; case 2:case 3:case 6: break;case 0:case 5: s+=2; break;cout mai。
4、n()int i=1,s=3; dos+=i+;if (s%7=0)continue; else+i; while (s main()int i,j;for (i=4;i=1;i-)cout main()int i,j,k;for (i=1;i main()int i,j,k;for (i=1;i0;k-) cout main()int i,j,k;for (i=1;i0;i-)for (j=1;j=20-3*i;j+) cout ;for (k=1;k=2*i-1;k+) cout*;coutendl;输出结果:*“”“”At the end, Xiao Bian gives you a p。
5、assage. Minand once said, people who learn to learn are very happy people. In every wonderful life, learning is an eternal theme. As a professional clerical and teaching position, I understand the importance of continuous learning, life is diligent, nothing can be gained, only continuous learning ca。
6、n achieve better self. Only by constantly learning and mastering the latest relevant knowledge, can employees from all walks of life keep up with the pace of enterprise development and innovate to meet the needs of the market. This document is also edited by my studio professionals, there may be errors in the document, if there are errors, please correct, thank you。