c语言程序设计课件ppt(英文)c program language 之4 control flows

c语言程序设计课件ppt(英文)c program language 之4 control flows

ID:17963316

大小:994.00 KB

页数:54页

时间:2018-09-11

c语言程序设计课件ppt(英文)c program language 之4 control flows_第1页
c语言程序设计课件ppt(英文)c program language 之4 control flows_第2页
c语言程序设计课件ppt(英文)c program language 之4 control flows_第3页
c语言程序设计课件ppt(英文)c program language 之4 control flows_第4页
c语言程序设计课件ppt(英文)c program language 之4 control flows_第5页
资源描述:

《c语言程序设计课件ppt(英文)c program language 之4 control flows》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、ControlflowsChapterFourContentsBasiccontrolflowsinC1Ifstatement2Switchstatement3Loopstructure4Breakandcontinuestatements5gotoandlabels6BasiccontrolflowsinCThecontrol-flowofalanguagespecifytheorderinwhichcomputationsareperformed.SequenceStatementsareexecutedintheord

2、erofwrittingConditionTestthecondition,whentheresultistrue,executeA,otherwise,executeBLoopRepeatsomestatements.Whenconditionistrue,repeatA,stopwhilefalseRepeatA,stopwhentheconditionistrue.ABBasiccontrolflowsinCexpABYNForeachcontrolflow,thereisonlyonedataentrance,one

3、dataexit.YNstatementexpIfstatementHowcanwedividethescoresintopassandfail?Howcanwechangethescoresintofivegrades?Innatuallanguage:if……thenInClanguage:ifstatementTheif–elsestatementisusedtoexpressdecisions.Formallythesyntaxis:if(expression)statement1elsestatement2Wher

4、etheelsepartisoptional.Theexpressionisevaluated;ifitistrue,statement1isexecuted.Ifitisfalseandifthereisanelsepart,statement2isexcutedinstead.casesIfstatement(3)if(exp1)statement1elseif(exp2)statement2elseif(exp3)statement3……elsestatementn1、Threekindsofifstatement(1

5、)if(expression)statementexpstatementYN(2)if(expression)statement1elsestatement2expYNstatement2statement1exp1exp3statement3statementnexp2statement1Ystatement2YYNNNMulti-waydecisionIfstatementTheexpressionsareevaluatedinorder;ifanexpressionistrue,thestatementassociat

6、edwithitisexected,andthisterminatesthewholechain.IfstatementMulti-waydecision12Thissequenceofifstatementsisthemostgeneralwayofwritingamulti-waydecision.Thecodeforeachstatementiseithersinglestatement,oragroupoftheminbraces.3Thelastelseparthandlesthe“noneoftheabove“o

7、radefaultcasewherenoneoftheotherconditionsissatisfied.main(){inta;scanf(“%d”,&a);if(a<10)printf(“%d<10”,a);elseif(a<100)printf(“10<%d<100”,a);elseif(a<1000)printf(“<100<%d<1000”,a);elseprintf(“%d>1000”,a);}1010&&A<100Ifstatement2nesting-ifstatementi

8、f(exp)if(exp1)statement11elsestatement12elseif(exp2)statement21elsestatement22Ifstatementexpstatement11exp2exp1YYYNNNstatement12statement21statem

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。