flowchart structure 25th october 2018€¦ · flowchart structure ... question: with the aid of...
TRANSCRIPT
25th October 2018
Flowchart Structure
Section 1: Basic rules in flowchart
Section 2: Translating Pseudocode to Flowchart Algorithm
Section3: Examples of Flowchart
Section 4: Control structures (Sequence, Selection, Repetition
Flowchart - a traditional graphical tool with standardized symbols. Show the sequence of steps in an algorithm.
• Flowcharts are also called block diagrams, flow diagrams, system charts, procedural charts, run diagrams and logic charts.
1. The flowchart should flow from top to bottom
2. If the chart becomes complex, utilize connecting
blocks
3. Avoid intersecting flow lines
4. Use meaningful description in the symbol
NB: Appropriate use of flow symbols are critical in program flowchart than the other three (3)
TYPES of
FLOWCHARTS
System
Outline charts
System
Flowcharts Run Flowcharts Program
Flowcharts
1. Complex- The major disadvantages in using the flowcharts is that when a program is very large, the flowcharts may continue for many pages, making them hard to follow.
2. Costly- Drawing flowcharts are viable only if the problem solving logic is straight forward and not very lengthy. However , if flowcharts are to be drawn for a huge application, the time and cost factor of program development may get out of proportion.
3. Difficult to modify- due to symbolic nature, any changes of modifications to a flowcharts usually requires redrawing the entire logic again, and redrawing a complex flowchart is not a simple tasks.
4. No update: usually program are updated regularly . However corresponding update in the flowchart may not take place, especially in the case of large programs. As a result the logic in flowchart may not match with the actual program; causing logical error.
Relational Operators
Operator Description
> Greater than
< Less than
= Equal to
Greater than or equal to
Less than or equal to
Not equal to
SYMBOL NAME DESCRIPTION
TERMINAL Start/Stop Begin/End
Defines the starting and ending point of a flowchart.
INITIALIZATION
The preparation or initialization of memory space for data processing.
INPUT/OUTPUT The inputting of data for processing, and printing out of processed data.
PROCESS Manipulation of data(assignments and mathematical computations)
FLOW LINES
Defines logical sequence of the program. Its points to the ext symbol to be performed
DECISION MAKING
Process conditions using relational operators. Used for trapping and filtering data.
Flowcharting Symbols
Control Structures Application
Examples: Flowcharts Sequence
• So let’s say we want to express the following algorithm: – Read in a number and print it out.
START
Every programming has Start point and End point to avoid infinity execution
START
Read in A
Read is the input to be processed during the execution/running
START
Read in A
Print A
Print is the Output/results after the processing of A
START
END
Read in A
Print A
End means the system has to stop running. We have obtained the results
Examples: Flowcharts Selection
• So let’s say we want to express the following algorithm:
– Read in a number, check if it is odd or even.
•
START
START
Read in A
START
Does A/2 give a
remainder?
Read in A
Introduction of selection/Decision symbol
START
Does A/2 give a
remainder?
Read in A
Yes Print “It’s Odd”
START
Does A/2 give a
remainder?
No
Read in A
Yes Print “It’s Odd” Print “It’s Even”
START
END
Does A/2 give a
remainder?
No
Read in A
Yes Print “It’s Odd” Print “It’s Even”
Examples: Flowcharts Iteration
• So let’s say we want to express the following algorithm: – We want to wash our hand under a tap until hands are clean.
Dispense Soap
Turn on Water
Rub Hands Together
Rinse Soap Off
Turn off Water
Dry Hands
Start
Hands Clean?
NO
YES
END
Wash Hands till Clean (Iteration/loop/while)
Start
Wet Hair
Set Wash Count To 0
Add 1 to value of Wash Count
Rinse Hair
Lather Hair
Wash Count =2?
Stop
Yes
No
Flow chart to explain how to wash your hair
Example: 3 Complex
PRINT “PASS”
Pseudocode: Start Step 1: Input M1,M2,M3,M4 Step 2: GRADE (M1+M2+M3+M4)/4 ; Step 3: If (GRADE <50) then Print “FAIL” else Print “PASS” endif stop
START
Input M1,M2,M3,M4
GRADE(M1+M2+M3+M4)/4
IS GRADE<50
PRINT “FAIL”
STOP
Y N
Write an algorithm in pseudocode and draw a flowchart to convert the length in feet to centimeter.
Pseudocode: Begin Input the length in feet (Lft); Calculate the length in cm (Lcm) by multiplying
LFT with 30; Print length in cm (LCM); End
Algorithm
Step 1: Input Lft
Step 2: Lcm Lft x 30
Step 3: Print Lcm
START
Input Lft
Lcm Lft x 30
Print Lcm
STOP
Flowchart
Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years.
Write definite procedure and use the following set of rules in the algorithm: Sequence, selection and iterations (optional) where necessary.
NB: Consider in the process;
1. National Service
2. Job Market Entry/self-employment
3. Marriage,
4. Expectancy: 1st Child, 2nd Child, 3rd Child nth Child
5. Master Degree (2years)
6. PHD (4years+1year language studies in some countries)
7. Abroad visit/stay (optional)
Summary: 1. Pseudocode
2. Flowchart
3. Translating Pseudocode to flowchart
4. Coding unto machine-VB Platform
(4) Lab Assignment:
Use Visual Basics to Implement Algorithm.
Download assignment from Sakai
Thank you