Introduction To Flowcharting
Today’s Topics Flowchart Symbols
Structures
Sequence
Selection
RepetitionFlowchart:Represents an algorithm in graphical symbols
Flowchart Symbols
Flowchart Symbols
Comments or description
Connectors on the same page 1- connection on the same flowchart portion2- connection on the differentflowchart portion
Connectors on a different page Page 2Page 1
The detail of how the function worksis put in another flowchart. This is known as Function-DefinitionPage 1Page 2Start terminal for aFunction is different.Do not use “Start”Body of a function is the same with normal flowchartAt this point, we only focus on whatto do. How to do it,  it comes later.This part is known asFunction-CallEnd terminal must be a “Return”FunctionThis flowchart calculates the average of three numbers
The main flowcharting structuresSequenceSelectionRepetition A flowchart expressing the solution to an involved problem may have:the main program flowchart on one page with subprograms continuing the problem solution on subsequent pages.
Each of the five acceptable structures can be built from the basic elements as shown below.
Each of the five acceptable structures can be built from the basic elements as shown below.
Each of the five acceptable structures can be built from the basic elements as shown below.
SequenceIn a computer program or an algorithm, sequence involves simple steps which are to be executed one after the other. The steps are executed in the same order in which they are written.In a flowchart, sequence is expressed as:In pseudocode, sequence is expressed as:process 1process 2……process n
SequenceAn Example Using SequenceProblem: Write a set of instructions that describe how to make a pot of tea.PseudocodeBEGINfill a kettle with waterboil the water in the kettleput the tea leaves in the potpour boiling water in the potENDFlowchart
Selection is used in a computer program or algorithm to determine which particular step or set of steps is to be executedBinary SelectionIn pseudocode, binary selection is expressed in the following ways:   IF condition THENprocess 1ENDIFIF condition THENprocess 1ELSEprocess 2ENDIFBinary SelectionIn flowcharts, binary selection is expressed in the following ways:
SelectionBinary (structure)Binary SelectionIn pseudocode, binary selection is expressed in the following ways:  IF condition THENprocess 1ENDIF  IF condition THENprocess 1ELSEprocess 2ENDIFBinary SelectionIn flowcharts, binary selection is expressed in the following ways:
SelectionBinary (flowchart structure)Note: In a flowchart it is most important to indicate which path is to be followed when the condition is true, and which path to follow when the condition is false. Without these indications the flowchart is open to more than one interpretation.Note: There are two acceptable ways to represent a decision in all of the structures.Either method is acceptable. For consistency, the method 1 is used throughout this document.The condition is expressed as a statement and the two possible outcomes are indicated byTrue
False2.  The condition is expressed as a question and the two possible outcomes are indicated by Yes
NoSelectionBinary (examples)Selection is used in a computer program or algorithm to determine which particular step or set of steps is to be executed.Examples Using Binary SelectionProblem 1: Write a set of instructions to describe when to answer the phone. Binary SelectionFlowchartBinary SelectionPseudocodeIF the telephone is ringing THENanswer the telephoneENDIF
SelectionBinary (examples)Examples Using Binary SelectionProblem 2: Write a set of instructions to follow when approaching a set of traffic control lights.Binary SelectionFlowchartBinary SelectionPseudocodeIF the signal is green THENproceed through the intersectionELSEstop the vehicleENDIF
SelectionMulti-way (structure)Multi-way SelectionIn flowcharts, multi-way selection is expressed as:Multi-way SelectionIn pseudocode, multiple selection is expressed as:CASEWHERE expression evaluates tochoice a      :      process achoice b      :      process b      . 		     .      . 		     .      . 		     .    OTHERWISE  :      default processENDCASENote: As the flowchart version of the multi-way selection indicates, only one process on each pass is executed as a result of the implementation of the multi-way selection.
SelectionMulti-way (examples)Example Using Multi-way SelectionProblem: Write a set of instructions that describes how to:respond to all possible signals at a set of traffic control lights.Multi-way SelectionFlowchartMulti-way SelectionPseudocodeCASEWHERE signal isred              : stop the vehicleamber         : stop the vehiclegreen          : proceed through the intersection     OTHERWISE  : proceed with cautionENDCASE
RepetitionRepetition allows for a portion of an algorithm or computer programto be done any number of times dependent on some condition being met. An occurrence of repetition is usually known as a loop.An essential feature of repetition is that each loop has a termination condition to stop the repetition, or the obvious outcome is that the loop never completes execution (an infinite loop). The termination condition can be checked or testedat the beginning and is known as a pre-test loop orat the end of the loop and is known as a post-test loop.
RepetitionPre-test(structure)Repetition: Pre-TestA pre-tested loop is so named because the condition has to be met atthe very beginning of the loop or the body of the loop is not executed. This construct is often called a guarded loop. Thebody of the loop is executed repeatedly while the termination condition is true.RepetitionIn flowchartingpre-test repetition is expressed as:RepetitionIn pseudocode, pre-test repetition is expressed as:WHILE condition is trueprocess(es)ENDWHILE
Repetition Post-test(structure)Repetition: Post-TestA post-tested loop executes the body of the loop before testing the termination condition.
This construct is often referred to as an unguarded loop.
The body of the loop is repeatedly executed until the termination condition is true.An important difference between a pre-test and post-test loop is that the statements of a post-test loop are executed at least once even if the condition is originally true, whereas the body of the pre-test loop may never be executed if the termination condition is originally true. A close look at the representations of the two loop types makes this point apparent.RepetitionIn a flowchartpost-test repetition is expressed as:RepetitionIn pseudocode, post-test repetition is expressed as:REPEATprocessUNTIL condition is true
Repetition Pre-test(example)An Example Using Pre-Test RepetitionProblem: Determine a safety procedure for travelling in a carriage on a moving train.Pre-test RepetitionFlowchartPre-test RepetitionPseudocodeWHILE the train is movingkeep wholly within the carriageENDWHILE
Repetition Post-test(example)An Example Using Post-Test RepetitionProblem: Determine a procedure to beat egg whites until fluffy.Post-test RepetitionFlowchartPost-test RepetitionPseudocodeREPEATbeat the egg whitesUNTIL fluffy
Input:Length <- 5Width  <- 3Process:Area = 5 * 3 = 15Process:Perimeter =       2* (5+3)    = 16OutputArea: 15Perimeter: 16Example:

Introduction to flowchart

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
    Connectors on thesame page 1- connection on the same flowchart portion2- connection on the differentflowchart portion
  • 11.
    Connectors on adifferent page Page 2Page 1
  • 12.
    The detail ofhow the function worksis put in another flowchart. This is known as Function-DefinitionPage 1Page 2Start terminal for aFunction is different.Do not use “Start”Body of a function is the same with normal flowchartAt this point, we only focus on whatto do. How to do it, it comes later.This part is known asFunction-CallEnd terminal must be a “Return”FunctionThis flowchart calculates the average of three numbers
  • 13.
    The main flowchartingstructuresSequenceSelectionRepetition A flowchart expressing the solution to an involved problem may have:the main program flowchart on one page with subprograms continuing the problem solution on subsequent pages.
  • 14.
    Each of thefive acceptable structures can be built from the basic elements as shown below.
  • 15.
    Each of thefive acceptable structures can be built from the basic elements as shown below.
  • 16.
    Each of thefive acceptable structures can be built from the basic elements as shown below.
  • 17.
    SequenceIn a computerprogram or an algorithm, sequence involves simple steps which are to be executed one after the other. The steps are executed in the same order in which they are written.In a flowchart, sequence is expressed as:In pseudocode, sequence is expressed as:process 1process 2……process n
  • 18.
    SequenceAn Example UsingSequenceProblem: Write a set of instructions that describe how to make a pot of tea.PseudocodeBEGINfill a kettle with waterboil the water in the kettleput the tea leaves in the potpour boiling water in the potENDFlowchart
  • 19.
    Selection is usedin a computer program or algorithm to determine which particular step or set of steps is to be executedBinary SelectionIn pseudocode, binary selection is expressed in the following ways: IF condition THENprocess 1ENDIFIF condition THENprocess 1ELSEprocess 2ENDIFBinary SelectionIn flowcharts, binary selection is expressed in the following ways:
  • 20.
    SelectionBinary (structure)Binary SelectionInpseudocode, binary selection is expressed in the following ways: IF condition THENprocess 1ENDIF IF condition THENprocess 1ELSEprocess 2ENDIFBinary SelectionIn flowcharts, binary selection is expressed in the following ways:
  • 21.
    SelectionBinary (flowchart structure)Note:In a flowchart it is most important to indicate which path is to be followed when the condition is true, and which path to follow when the condition is false. Without these indications the flowchart is open to more than one interpretation.Note: There are two acceptable ways to represent a decision in all of the structures.Either method is acceptable. For consistency, the method 1 is used throughout this document.The condition is expressed as a statement and the two possible outcomes are indicated byTrue
  • 22.
    False2. Thecondition is expressed as a question and the two possible outcomes are indicated by Yes
  • 23.
    NoSelectionBinary (examples)Selection isused in a computer program or algorithm to determine which particular step or set of steps is to be executed.Examples Using Binary SelectionProblem 1: Write a set of instructions to describe when to answer the phone. Binary SelectionFlowchartBinary SelectionPseudocodeIF the telephone is ringing THENanswer the telephoneENDIF
  • 24.
    SelectionBinary (examples)Examples UsingBinary SelectionProblem 2: Write a set of instructions to follow when approaching a set of traffic control lights.Binary SelectionFlowchartBinary SelectionPseudocodeIF the signal is green THENproceed through the intersectionELSEstop the vehicleENDIF
  • 25.
    SelectionMulti-way (structure)Multi-way SelectionInflowcharts, multi-way selection is expressed as:Multi-way SelectionIn pseudocode, multiple selection is expressed as:CASEWHERE expression evaluates tochoice a : process achoice b : process b . . . . . . OTHERWISE : default processENDCASENote: As the flowchart version of the multi-way selection indicates, only one process on each pass is executed as a result of the implementation of the multi-way selection.
  • 26.
    SelectionMulti-way (examples)Example UsingMulti-way SelectionProblem: Write a set of instructions that describes how to:respond to all possible signals at a set of traffic control lights.Multi-way SelectionFlowchartMulti-way SelectionPseudocodeCASEWHERE signal isred : stop the vehicleamber : stop the vehiclegreen : proceed through the intersection OTHERWISE : proceed with cautionENDCASE
  • 27.
    RepetitionRepetition allows fora portion of an algorithm or computer programto be done any number of times dependent on some condition being met. An occurrence of repetition is usually known as a loop.An essential feature of repetition is that each loop has a termination condition to stop the repetition, or the obvious outcome is that the loop never completes execution (an infinite loop). The termination condition can be checked or testedat the beginning and is known as a pre-test loop orat the end of the loop and is known as a post-test loop.
  • 28.
    RepetitionPre-test(structure)Repetition: Pre-TestA pre-testedloop is so named because the condition has to be met atthe very beginning of the loop or the body of the loop is not executed. This construct is often called a guarded loop. Thebody of the loop is executed repeatedly while the termination condition is true.RepetitionIn flowchartingpre-test repetition is expressed as:RepetitionIn pseudocode, pre-test repetition is expressed as:WHILE condition is trueprocess(es)ENDWHILE
  • 29.
    Repetition Post-test(structure)Repetition: Post-TestApost-tested loop executes the body of the loop before testing the termination condition.
  • 30.
    This construct isoften referred to as an unguarded loop.
  • 31.
    The body ofthe loop is repeatedly executed until the termination condition is true.An important difference between a pre-test and post-test loop is that the statements of a post-test loop are executed at least once even if the condition is originally true, whereas the body of the pre-test loop may never be executed if the termination condition is originally true. A close look at the representations of the two loop types makes this point apparent.RepetitionIn a flowchartpost-test repetition is expressed as:RepetitionIn pseudocode, post-test repetition is expressed as:REPEATprocessUNTIL condition is true
  • 32.
    Repetition Pre-test(example)An ExampleUsing Pre-Test RepetitionProblem: Determine a safety procedure for travelling in a carriage on a moving train.Pre-test RepetitionFlowchartPre-test RepetitionPseudocodeWHILE the train is movingkeep wholly within the carriageENDWHILE
  • 33.
    Repetition Post-test(example)An ExampleUsing Post-Test RepetitionProblem: Determine a procedure to beat egg whites until fluffy.Post-test RepetitionFlowchartPost-test RepetitionPseudocodeREPEATbeat the egg whitesUNTIL fluffy
  • 34.
    Input:Length <- 5Width <- 3Process:Area = 5 * 3 = 15Process:Perimeter = 2* (5+3) = 16OutputArea: 15Perimeter: 16Example:
  • 35.
    Input:Num <- 10Entera Number >> 10Num = 1010 > 0 ? => YESOutput:“Category A”Example: What is the output of the following flowchart when the input Num= 10Category A
  • 36.
    Input:Num <- 0Entera Number >> 0Num = 00 > 0 ? => NOOutput:“Category B”Output:“Category A”Example: What is the output of the following flowchart when the input is Num= 0Category BCategory A
  • 37.
    Variables (in memory):Num [ 4 ]Result [ ]Count [ ]Input:Num <- 4Enter a Number => 4Count = 44 > 0 ? => YESCount = 33 > 0 ? => YESCount = 22 > 0 ? => YESCount = 11 > 0 ? => YESCount = 00 > 0 ? => NOExample: What is the output of the following flowchart when the input is Num= 4Variables (in memory):Num [ 4 ]Result [ 0 ]Count [ 4 ]Variables (in memory):Num [ 4 ]Result [ 7 ] 4 + 3Count [ 2 ] 3 - 1Variables (in memory):Num [ 4 ]Result [ 9 ] 7 + 2Count [ 1 ] 2 - 1Variables (in memory):Num [ ]Result [ ]Count [ ]Variables (in memory):Num [ 4 ]Result [ 10] 9 + 1Count [ 0 ] 1 - 1Variables (in memory):Num [ 4 ]Result [ 4 ] 0 + 4Count [ 3 ] 4 - 1Count: 4Count: 3Count: 2Count: 1Count: 0Result: 10
  • 38.
    Example: What isthe output of the following flowchart when the input is N = 6105averageN=6Sum = 10 + 5 + 6average = 21/3Output:Average: 7Page 1Page 2
  • 39.
  • 40.
    QuizWhat is aflowchart?It is used to connect remote flowchart portion on the same page. One flow line enters and one flow line exits.3-5. Control Structures of Flowchart.