- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
大连东软信息学院大一上电子工程c语言实验第四次,第八周.doc
Lab4 Looping Structures
OBJECTIVES
After completing this experiment, you will be able to:
Use incrementing and decrementing operators
Use while structure and do-while structure
Use for structure
Use break and continue statements
PROCEDURES
PART 1 use ++ and --
. #include stdio.h
void main()
{
int a=5,b=5;
printf(“value a=%d\n”,a++);/
printf(“value b=%d\n”,++b);
printf(“value a=%d\n”,--a);
printf(“value b=%d\n”,b--);
}
Print Screen of Result:
棗棗棗棗棗棗棗棗棗
Print SSummarize the the difference between a++ and ++a in your words.
Different running order.
棗棗棗棗棗棗棗棗棗
PART2 use while and do while structure.
/*Get the number that can not be divided by 3 between 100 and 200 */
()
{
i#include stdio.h
main()
{
int i=100;
while (i=200)
{
if(i%3)
printf(%5d,i);
i++;
}
}
Print Screen of Result:
棗棗棗棗棗棗棗棗棗reen of R
Rewrite it using do-while loop.
Print Screen of code:
棗棗棗棗棗棗棗棗棗using do-
PART 3 use for structure.
1.Write a program to give the result of 1!+2!+3!+…+n!
#include stdio.h
void main()
{
long int s=1,t;
int i,j,n;
printf(n=);
scanf(%d,n);
for(i=2;i=n;i++)
{
for(t=1,j=1;j=i;j++)
t*=j;
s+=t;
}
printf(s=%ld\n,s);
}
Print Screen of Result:
棗棗棗棗棗棗棗棗棗reen of R
Use different data to test the program, find the number on which the result number will overflow
棗棗棗棗棗棗棗棗棗
Try to use only one loop to solve the problem
Print Screen of code:
棗棗棗棗棗棗棗棗棗rflow
nf(%d,n)
2. Print out the following table using nested for loop.
Print Screen of code:
棗棗棗棗棗棗棗棗棗t out the
PART 4 use break and continue structure.
1.Prompt the user to input an integer, get the number of the user’s input between 0 and 100 .
#include stdio.h
void main()
{
int m,counter=0;
while(1)
{
printf(input a positive integer (0 means end):);
scanf(%d,m);
if(m0) break;
if(m100)counter++;
printf(\n);
}
printf(\n numbers less than 100: %d\n,counter);
}
Print Screen of Result:
—————————————————
2.
#include stdio.
您可能关注的文档
- 在观念与形式之间.doc
- 在图示机构中,沿斜面纯滚动的圆柱体.doc
- 地图在区域地理学习中的应用.ppt
- 地形和表示地形的地图第二课时.ppt
- 地理信息系统的应用及发展趋势.pdf
- 地理第四次考试及答案.doc
- 城中村有序改造的群决策——以广州市城中村改造为例.pdf
- 城市化下基于多等级湿地理论的河流湿地功能修复途径探讨――以宜昌市运河公园为例.pdf
- 城市建设中的旧城改造问题思考.pdf
- 城市相对集中行政处罚权的矛盾与求解对策.pdf
- 四川雅江县公安局公开招聘警务辅助人员20人告备考题库及参考答案详解一套.docx
- 关于山东大学齐鲁医院(青岛)2025年度部分非事业编制岗位招聘的备考题库及答案详解参考.docx
- 化州市公安局2025年招聘警务辅助人员备考题库及答案详解参考.docx
- 儋州市卫生健康委员会2025年面向社会考核招聘卫健系统事业单位编内人员备考题库(一号)及参考答案详解.docx
- 北京市怀柔区卫生健康委员会所属事业单位2026年第一批公开招聘医务人员备考题库参考答案详解.docx
- 云南省昆明市晋宁区人民法院2025年公开招聘合同制人员备考题库带答案详解.docx
- 内江市公安局高新技术开发区分局2025年第三次招聘警务辅助人员备考题库及1套完整答案详解.docx
- 中国科学院山西煤炭化学研究所2025年度编制外人员招聘备考题库(908组)含答案详解.docx
- 乐山师范学院2026届高层次人才招聘备考题库及答案详解一套.docx
- 佛山市里水中学2025-2026学年教师招聘备考题库及答案详解1套.docx
原创力文档


文档评论(0)