flowchart structure 25th october 2018€¦ · flowchart structure ... question: with the aid of...

31
25 th October 2018 Flowchart Structure

Upload: others

Post on 18-Oct-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

25th October 2018

Flowchart Structure

Page 2: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write
Page 3: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

Section 1: Basic rules in flowchart

Section 2: Translating Pseudocode to Flowchart Algorithm

Section3: Examples of Flowchart

Section 4: Control structures (Sequence, Selection, Repetition

Page 4: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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

Page 5: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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

Page 6: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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.

Page 7: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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.

Page 8: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

Relational Operators

Operator Description

> Greater than

< Less than

= Equal to

Greater than or equal to

Less than or equal to

Not equal to

Page 9: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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

Page 10: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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.

Page 11: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

Every programming has Start point and End point to avoid infinity execution

Page 12: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

Read in A

Read is the input to be processed during the execution/running

Page 13: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

Read in A

Print A

Print is the Output/results after the processing of A

Page 14: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

END

Read in A

Print A

End means the system has to stop running. We have obtained the results

Page 15: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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.

Page 16: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

Page 17: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

Read in A

Page 18: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

Does A/2 give a

remainder?

Read in A

Introduction of selection/Decision symbol

Page 19: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

Does A/2 give a

remainder?

Read in A

Yes Print “It’s Odd”

Page 20: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

Does A/2 give a

remainder?

No

Read in A

Yes Print “It’s Odd” Print “It’s Even”

Page 21: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

START

END

Does A/2 give a

remainder?

No

Read in A

Yes Print “It’s Odd” Print “It’s Even”

Page 22: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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.

Page 23: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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)

Page 24: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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

Page 25: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

Example: 3 Complex

Page 26: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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

Page 27: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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

Page 28: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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

Page 29: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write
Page 30: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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)

Page 31: Flowchart Structure 25th October 2018€¦ · Flowchart Structure ... Question: With the aid of flowchart diagram, programme your future and career life for the next 7-10years. Write

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