C语言学习第二章(英文版)课件.ppt
- 【下载声明】
1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
3. 本页资料《C语言学习第二章(英文版)课件.ppt》由用户(晟晟文业)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 学习 第二 英文 课件
- 资源描述:
-
1、The number of the group:The number of the group:7716202377162023Chapter 2 Chapter 2 Algorithm and FlowchartAlgorithm and Flowchartn2.1 What is algorithmn2.2 Features of algorithmsn2.3 Pseudocoden2.4 Flowchartn2.5 Control Structuresn2.6 Selection Structuren2.7 Repetition StructureOutlineOutlineKey po
2、intsKey pointsnWhat is algorithmnFeatures of algorithmsnFlowchart2.2.1 What is algorithm1 What is algorithmnBefore writing a program:nHave a thorough understanding of the problem nCarefully plan an approach for solving itnWhile writing a program:nKnow what”building blocks”are availablenUse good prog
3、ramming principles2.2.1 What is algorithm1 What is algorithm A step-by-step problem-solving procedure,especially an established,recursive computational procedure for solving a problem in a finite number of steps.2.2.2 Features of algorithm2 Features of algorithmnDeterminismnAn algorithm is determini
4、stic,if at any stage of the algorithm execution,the next action step is clearly defined.nFinitenessnThe finiteness restricts the definition of the algorithm to a finite long-term operation.nEffectivenessnThe effect of each statement of an algorithm must be clearly defined.2.2.3 Pseudocode3 Pseudocod
5、enPseudocodenArtificial,informal language that helps us develop algorithmsnSimilar to everyday EnglishnNot actually executed on computers nHelps us“think out”a program before writing it nEasy to convert into a corresponding C programnConsists only of executable statements2.2.3 Pseudocode3 Pseudocode
6、nExample of pseudocode nIf students grade is greater than or equal to 60 Print“Passed”nIf students grade is greater than or equal to 60 Print“Passed”else Print“Failed”2.2.4 Flowchart4 FlowchartnFlowchart nGraphical representation of an algorithmnDrawn using certain special-purpose symbols connected
7、by arrows called flowlinesnRectangle symbol(action symbol):nIndicates any type of actionnOval symbol:nIndicates the beginning or end of a program or a section of codenSingle-entry/single-exit control structures nConnect exit point of one control structure to entry point of the next(control-structure
8、 stacking)nMakes programs easy to build2.2.5 Control Structures5 Control StructuresnSequential execution nStatements executed one after the other in the order writtennTransfer of controlnWhen the next statement executed is not the next one in sequencenOveruse of goto statements led to many problemsn
9、 Bohm and JacopininAll programs written in terms of 3 control structuresnSequence structures:Built into C.Programs executed sequentially by defaultnSelection structures:C has three types:if,if/else,and switch(book chapter 4)nRepetition structures:C has three types:while,do/while and forn Single-entr
10、y/single-exit control structures nConnect exit point of one control structure to entry point of the next(control-structure stacking)nMakes programs easy to build2.2.5 Control Structures5 Control Structures2.2.6 Selection Structure(if)6 Selection Structure(if)nSelection structure:nUsed to choose amon
11、g alternative courses of actionnPseudocode:nIf students grade is greater than or equal to 60Print“Passed”nIf condition true nPrint statement executed and program goes on to next statementnIf false,print statement is ignored and the program goes onto the next statementnIndenting makes programs easier
12、 to readnC ignores whitespace characters2.2.6 Selection Structure(if)6 Selection Structure(if)nPseudocode statement in C:if(grade=60)printf(Passedn);nC code corresponds closely to the pseudocodenDiamond symbol(decision symbol)nIndicates decision is to be madenContains an expression that can be true
13、or falsenTest the condition,follow appropriate path2.2.6 Selection Structure(if)6 Selection Structure(if)nif structure is a single-entry/single-exit structureyesnograde=60print“Passed”A decision can be made on any expression.zero-no nonzero-yesExample:3-4 is yes2.2.6 Selection Structure(if)6 Selecti
14、on Structure(if)n Page 32 nIf you type a number less than 10,you get a message“What an obedient servant you are!”on the screen.nOtherwise,the program doesnt do anything.STARTPRINT enter a num less than 10 INPUT num is num=60)printf(Passedn);else printf(Failedn);nConditional operator(?:)nTakes three
15、arguments(condition,value if true,value if false)nOur pseudocode could be written:printf(%sn,grade=60?Passed:Failed);nOr it could have been written:grade=60?printf(“Passedn”):printf(“Failedn”);2.2.6 Selection Structure(if/else)6 Selection Structure(if/else)nFlow chart of the if/else selection struct
16、urenNested if/else structures nTest for multiple cases by placing if/else selection structures inside if/else selection structuresnOnce condition is met,rest of statements skippednDeep indentation usually not used in practiceyesnoprint“Failed”print“Passed”grade=602.2.6 Selection Structure(if/else)6
展开阅读全文