Flow Charts

  1. What is a problem?
  2. Problem solving techniques
  3. Algorithm
  4. Flowcharts
    1. Flow chart symbols/notations
    2. Basic symbols
    3. Line symbols
    4. Special symbols
    5. Data symbols
    6. Process symbols
  5. Flow control structures
    1. Sequences
    2. Selections
      1. If
      2. If/else
      3. Switch/ case
    3. Iteration
      1. While loop
      2. Do while loop
      3. Repeat Until
      4. For next loop
  6. Questions and Answers
  7. References

What is a problem?

                  A problem is an obstacle, impediment, difficulty or challenge, or any situation that invites resolution; the resolution of which is recognized as a solution or contribution toward a known purpose or goal.


Problem Solving Techniques

There are many problem solving techniques we can use to solve problems. Some are shown below...

  • Structured approach
  • Top down approach
  • Brute force approach
  • Divide and conquer approach

Algorithm is an example for the structured approach   problem solving method…. 

What is Algorithm?

          In mathematics and computer science, an algorithm  is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning. More precisely, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a functionAlgorithm can be represented in two ways,
  1. Graphically 
    • Flow charts
    • HIPO charts (Hierarchy plus Input Process Output)
  2. Textually
    • Pseudo codes

What is a Flow Chart?

         A flowchart is a type of diagram that represents an algorithm or process, showing the steps as boxes of various kinds, and linked together with arrows showing the process flow direction. This diagrammatic representation can give a step-by-step solution to a given problem.

Symbols used in Flow Charts



We can divide those main symbols in to four main groups

  • Line Symbols
  • Special Symbols
  • Data Symbols
  • Process Symbols





 


            
                   You can make your flowcharts, easier to understand and less subject to errors by using flow control structures……

Flow Control Structures


                    There are some standard ways of connecting the symbols to represent the three basic structures.. Each structure has a simple flow of control with one input and one output. These structures can then be nested within each other. Any chart can be drawn using only these structures. There are three basic Structures,
  1. Sequences
  2. Selections
  3. Iterations (Repetition) 

Sequence

                    The flowchart above demonstrates a sequence of steps. The reader would start at the Start shape and follow the arrows from one rectangle to the other, finishing at the End shape.  A sequence is the simplest flow charting construction. You do each step in order. 

                    If your charts are all sequences, then you probably don't need to draw a flowchart. You can type a simple list using your word processor. The power of a flowchart becomes evident when you include decisions and loops.


Selection

             This structure is called a decision, "If Then.. Else" or a conditional. A question is asked in the decision shape. Depending on the answer the control follows either of two paths.

IF/ THEN... ELSE



               In the chart above, if the temperature is going to be less than freezing (32 degrees Fahrenheit) the tomatoes should be covered……

"True" and "False" are also included in most of the flow charting stencils.


The flowchart for both an IF and an IF / ELSE structure are shown below. 


                      The distinguishing characteristic that identifies an IF statement over the other control structures is the flow of the program after the decision and resulting process.  In either an IF or IF / ELSE structure, the program flow continues to go down the page.

Switch Case


The structure above is called the case structure or selection structure.

The decision works fine if you have only two outputs, but if there are several, then using multiple decisions makes the chart too busy.

Since the case structure can be constructed using the decision structure, it is superfluous, but useful.

The case structure helps make a flowchart more readable and saves space on the paper…


The Switch Case structure is similar to a host of if statements.  The switch case structure may have a default condition that is executed if none of the statements match.  A switch/case structure is used when one statement must be chosen from many.

Iteration


This structure allows you to repeat a task over and over (to automate the System)…





                        The red chart above on the left does the task and repeats doing the task until the condition is true. The green chart on the right checks the condition first and does the task while the condition is true.

While Loop / While Do Loop

               In a While Loop, the expression is evaluated when the program enters the top of the loop.  If the expression is true, the statements within the loop are executed.  When the bottom of the code block is reached, program flow is directed back to the top of the loop and the conditional is re-evaluated.  As long as the conditional is evaluated as true, the process repeats. IF the conditional is evaluated as false, then the code block is skipped.  Again, the flowchart for a While Loop is shown below.

Do While Loop

             The Do/While loop is very similar to the while loop. The major difference is that the expression or conditional is tested at the bottom of the loop.  This means that the body of the loop is executed at least one time regardless of the results of the conditional.
If the result of the conditional is true, then the loop body is repeated.  This process is repeated until the conditional is evaluated as false.




Repeat Until

In a Repeat-Until loop, the expression is evaluated at the bottom of the loop like as in Do-While loop.  The difference in Repeat Until loop over While loop is that in Repeat Until Loop is iterate until the condition becomes true.  As long as the conditional is evaluated as false, the process repeats.


For Loop

The For Loop is traditionally used to perform a task or repetitive event for a known number of iterations or in other words, it is used to implement count-controlled loops.The ‘for loop’ is made up of an 
  • initial condition,
  • a conditional expression, 
  • a modifier, 
  • and the body or the code block.

When the ‘for loop’ is encountered, the initial condition is executed.  The conditional expression is then evaluated as either true or false.

If the conditional is determined to be true, then the body of the loop is executed.  Upon reaching the bottom of the loop, the modifier is executed.

Program control is then returned to the conditional.  The conditional expression is re-evaluated, and if true, the body of the loop is executed again.

Each time the bottom of the code block is reached, the modifier is executed.  The loop continues to be executed until the conditional is evaluated as no longer true.

Again the flowchart for a For Loop is shown below.


             The basic shape of the flowchart resembles that of a While Loop.  The difference or characteristic that determines that it is a For Loop is that the initial condition, conditional, and modifier all refer to the same variable.

             The resemblance or similarities between the For Loop and While Loop go beyond the fact that the flowcharts look similar.  In actuality, any For Loop can be replaced or implemented with a While Loop.  However, not all While Loops can be replaced by a For Loop.







References:

  • http://www.rff.com/structured_flowchart.htm
  • http://web.ics.purdue.edu/~jricha14/Control_Statements/control_statements.htm
  • https://en.wikipedia.org/wiki/Flowchart
  • https://en.wikipedia.org/wiki/Algorithm
  • http://www.definitions.net/definition/Algorithm
  • http://docslide.us/documents/homc-programming-and-the-atmega16-micro-controller.html
  • STRUCTURED SOFTWARE TESTING - Arunkumar Khannur
(Please note that most of the information taken through internet)






Comments

  1. i made this for my assignment.. hope this will be useful..

    ReplyDelete
  2. මෙහි ඇති මෙලෝ දෙයක් මට නොතේරේ :( එත් වැඩේ එළ ය! මගේ සුබ පැතුම්! :ඩී :ඩී

    ReplyDelete
  3. hehe.. thaanks aswinda/D.. ithin theerenna hariyata kiyawanna epai.. :P :D :D

    ReplyDelete
  4. this blog is sooo amazing.. its very interesting =)

    ReplyDelete

Post a Comment

Popular posts from this blog

JAVA

How to Install Dynamics NAV 2015