Course Hero Logo

1.2.8.5 Program Flow (2).docx - Program Flow Introduction...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 7 pages.

77Program FlowIntroductionProgramming languages have a set of statements to determine how to reach a goal.The FLOW of these statements is CONTROLLED by 3 different structures:Sequencing(Performing one instruction after another)Selection(The program making decisions)Iteration(The program repeating, looping infinitely or for a setnumber of times)SequencingA sequence is a control structure where the computer executes every instruction inthe order in which they are written. Here is an example of sequencing in an algorithm:Each line is executed before moving on to the next.Selection – Conditional OperationsComputer Science UK Membership Site Licence: Do not share outside your centre.
77Often we want programs to act differently when certain conditions occur. Selection is acontrol structure which contains instructions that DO NOT have to be executed insequence (non-sequential).There are two main types of selection.Selection of 2 possible pathways (IF-THEN-ELSE statements)Multiple Selections (CASE statements (uses the keyword ELIF in Python))Selection of 2 – IF-THEN-ELSE STATEMENTSThese are used to see if a certain condition is true orfalse. IF the condition is true THEN a certain set ofinstructions will be executed. ELSE (condition is false)then a different set of instructions will be executed.Multiple Selection – CASE STATEMENTS (ELIF in Python)These are used to run one of many possible instructions based on various conditions.It makes use of CASE OF andENDCASE to select one instructionfrom a set of instructions,depending on the value of avariable. It does the same job asmultiple (nested) IF-ELSEstatements but is more efficient.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 7 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
NoProfessor
Tags
Control flow

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture