DOC PREVIEW
IUPUI CSCI 23000 - Program Control

This preview shows page 1-2-3-24-25-26-27-48-49-50 out of 50 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1OutlineOutline (cont)Structured Program DevelopmentStructured Program Development (cont)Control StructuresControl Structures (cont)Control Structures (cont.)Slide 9Semantics vs SyntaxSelection Structure: ifSelection Structure: if (cont)The if Selection Structure (cont.)Selection Structure: if/elseSelection Structure: if/else (cont)The if/else Selection Structure (cont.)Slide 17Slide 18Slide 19Slide 20Repetition Structure: whileSlide 22Slide 23The Essentials of RepetitionEssentials of Counter-Controlled RepetitionEssentials of Counter-Controlled Repetition (cont)Repetition Structure: forRepetition Structure: forThe for Structure (cont.)The for Structure (cont.)Multiple-Selection Structure: switchFlowchart of the switch structureSlide 33Slide 34Repetition Structure: do/whileFlowchart of the do/while repetition structureSlide 37The break and continue StatementsThe break and continue Statements (cont)continue Statementbreak StatementEquality (==) vs. Assignment (=) OperatorsEquality (==) vs. Assignment (=) Operators (cont)ExamplesExamples:Slide 46Summary: Structured ProgrammingSummary: Structured Programming (cont)Summary: Structured-ProgrammingSummary: Structured-Programming (cont)Dale RobertsProgram ControlDepartment of Computer and Information Science,School of Science, IUPUIFall 2003CSCI 230Dale Roberts, LecturerDale Roberts, [email protected]@cs.iupui.eduDale RobertsOutlineOutlineThis Topic IntroducesThis Topic IntroducesStructured Program DevelopmentStructured Program DevelopmentSelection StructureSelection Structureififif/elseif/elseAdditional repetition control structuresAdditional repetition control structureswhilewhileforfordodo//whilewhileDale RobertsOutline Outline (cont)(cont)switchswitch multiple selection structure multiple selection structurebreakbreak statement statementUsed for exiting immediately and rapidly from certain Used for exiting immediately and rapidly from certain control structurescontrol structurescontinuecontinue statement statementUsed for skipping the remainder of the body of a Used for skipping the remainder of the body of a repetition structure and proceeding with the next repetition structure and proceeding with the next iteration of the loopiteration of the loopDale RobertsStructured Program DevelopmentStructured Program DevelopmentBefore writing a program:Before writing a program:Have a thorough understanding of the problem Have a thorough understanding of the problem Carefully plan an approach for solving itCarefully plan an approach for solving itWhile writing a program: While writing a program: Know what “building blocks” are availableKnow what “building blocks” are availableUse good programming principlesUse good programming principlesDale RobertsStructured Program Development Structured Program Development (cont)(cont)AlgorithmsAlgorithmsComputing problems Computing problems All can be solved by executing a series of actions in a specific All can be solved by executing a series of actions in a specific orderorderAlgorithm: procedure in terms ofAlgorithm: procedure in terms ofActions to be executed Actions to be executed The order in which these actions are to be executedThe order in which these actions are to be executedProgram control Program control Specify order in which statements are to executedSpecify order in which statements are to executedDale RobertsControl StructuresControl StructuresPseudocodePseudocodeArtificial, informal language that helps us develop Artificial, informal language that helps us develop algorithmsalgorithmsSimilar to everyday EnglishSimilar to everyday EnglishNot actually executed on computers Not actually executed on computers Helps us “think out” a program before writing it Helps us “think out” a program before writing it Easy to convert into a corresponding C++ programEasy to convert into a corresponding C++ programConsists only of executable statementsConsists only of executable statementsDale RobertsControl StructuresControl Structures (cont)(cont)Control StructureControl StructureSequential executionSequential execution Statements executed one after the other in the order writtenStatements executed one after the other in the order writtenTransfer of controlTransfer of controlWhen the next statement executed is not the next one in When the next statement executed is not the next one in sequence. Ex: sequence. Ex: gotogotoOver use of Over use of gotogoto statements led to many problems statements led to many problemsneed to eliminate need to eliminate gotogoto statement statements1s2s3...sncontrols1s2s3...si...sj...sncontrolDale RobertsControl StructuresControl Structures (cont.)(cont.)All programs written in terms of 3 control All programs written in terms of 3 control structures structures (Bohm and Jacopini)Sequence structures: Built into C. Programs executed sequentially Sequence structures: Built into C. Programs executed sequentially by defaultby defaultSelection structures: three types: Selection structures: three types: ifif, , ifif//elseelse, and , and switchswitchRepetition structures: three types: Repetition structures: three types: whilewhile, , dodo//whilewhile and and forforFlowchart Flowchart Graphical representation of an algorithmGraphical representation of an algorithmDrawn using certain special-purpose symbols connected Drawn using certain special-purpose symbols connected by arrows called flow-linesby arrows called flow-linesRectangle symbol (action symbol):Rectangle symbol (action symbol):Indicates any type of actionIndicates any type of actionOval symbol:Oval symbol:Indicates the beginning or end of a program or a section of codeIndicates the beginning or end of a program or a section of codeDale RobertsControl StructuresControl Structures (cont.)(cont.)Single-entry/single-exit control structures Single-entry/single-exit control structures Connect exit point of one control structure to entry point of Connect exit point of one control structure to entry point of the next (control-structure stacking)the next (control-structure stacking)Makes programs easy to buildMakes programs easy to build…ControlStructure1ControlStructure2ControlStructure3Dale RobertsSemantics vs SyntaxSemantics vs SyntaxEvery language embodies the concepts of semantics and syntax. Every language embodies the concepts of semantics and syntax. Semantics is the meaning behind what is being said.Semantics is the meaning behind what is being said.Syntax is


View Full Document

IUPUI CSCI 23000 - Program Control

Download Program Control
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Program Control and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Program Control 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?