1
FLOWCHART
Programming & Algorithm
Outline
2
Element of computer
Computer language & Interpreter
Analysis & Algorithm
Algorithm structure
Element of computer
3
Computer language & Language Translator
4
Computer language
Machine Language
Low Level Language
High Level Language
Language Translator
Assembler
Compiler
Interpreter
Analysis & Algorithm
5
Analysis
Answer Analysis
Data Analysis
Process Analysis
Debug Analysis
Algorithm
Flowchart
Pseudo code
Introduction to Flowchart
6
A flowchart is a common type of chart, that
represents an algorithm or process, showing the
steps as boxes of various kinds, and their order by
connecting these with arrows. Flowcharts are used in
analyzing, designing, documenting or managing a
process or program in various fields
Types of flowcharts
7
Consist of
Document flowcharts, showing a document flow through
system
Data flowcharts, showing data flows in a system
System flowcharts, showing controls at a physical or
resource level
Program flowchart, showing the controls in a program
within a system
Symbol
8
Start and end symbols Represented as lozenges,
ovals or rounded rectangles, usually containing the
word "Start" or "End", or another phrase signaling
the start or end of a process, such as "submit
enquiry" or "receive product".
Arrows Showing what's called "flow of control" in
computer science. An arrow coming from one symbol
and ending at another symbol represents that
control passes to the symbol the arrow points to.
Symbol
9
Processing steps Represented as rectangles.
Examples: "Add 1 to X"; "replace identified part";
"save changes" or similar.
Input/Output Represented as a parallelogram.
Examples: Get X from the user; display X.
A Manual input represented by parallelogram, with
the top irregularly sloping up from left to right. An
example would be to signify data-entry from a
form;
Symbol
10
Conditional or decision Represented as a diamond
(rhombus). These typically contain a Yes/No
question or True/False test. This symbol is unique in
that it has two arrows coming out of it, usually from
the bottom point and right point, one corresponding
to Yes or True, and one corresponding to No or
False.
A Display Output represented by many rectangle
Flowchart Symbols
Symbols of flowchart to standard from ANSI
(The American National Standard Institute)
Symbols Description
Processing กระบวนการ การคานวณ
Auxiliary
Processing กระบวนการสารอง
11
Flowchart Symbols
12
Symbols Description
Subroutine กระบวนการที่นิยามไว้ การทางาน
Processing ย่อย
Input/Output ข้ อมูล รับหรื อแสดงข้ อมูลโดยไม่
Data ระบุชนิดอุปกรณ์
Internal
Storage ที่เก็บภายใน
Decision
Symbol การตัดสินใจ การเปรี ยบเทียบ
Flowchart Symbols
13
Symbols Description
Preparation การเตรี ยมการ การกาหนดค่า
Symbol ล่วงหน้ าหรื อกาหนดค่าเป็ นชุดตัวเลข
้
ปอนข้ อมูลด้ วยตนเอง การรับข้ อมูล
Manual Input ้
เข้ าทางแปนพิมพ์
้
ขันตอนที่ทาด้ วยตนเอง การควบคุม
้
Manual Control โปรแกรมทางแปนพิมพ์
Document เอกสารแสดงผล, การแสดงผลทาง
Output เครื่ องพิมพ์
Flowchart Symbols
14
Symbols Description
More Document เอกสารแสดงผลหลายฉบับ
Monitor จอภาพแสดงผล
Card การ์ ดหรื อบัตรเจาะรู ใช้ ใส่ข้อมูล
Tape เทป (สื่อบันทึกข้ อมูล)
Flowchart Symbols
15
Symbols Description
เริ่มต้ น/สิ ้นสุด, การเริ่มต้ นหรื อการ
Start/End Symbol ลงท้ าย
Connection
Symbol จุดเชื่อมต่อในหน้ าเดียวกัน
Connection
Symbol ตัวเชื่อมต่อไปหน้ าอื่น
จุดร่วมการเชื่อมต่อ
Flowchart Symbols
16
Symbols Description
หรื อ
ตรวจเทียบ
เรี ยงลาดับ
แยก
Flowchart Symbols
17
Symbols Description
ผนวก
ข้ อมูลที่เรี ยง
หน่วงเวลา
ที่เก็บแบบเข้ าถึงโดยเรี ยงลาดับ
Flowchart Symbols
18
Symbols Description
ดิสก์แม่เหล็ก
หน่วยเก็บแบบเข้ าถึงโดยตรง
Flow Line เส้ นแสดงลาดับกิจกรรม
Comment Line แสดงคาอธิบายหรื อหมายเหตุ
Usually Symbols
19
Read Reading of Keyboard
Read
Read Reading of other tools
Reading data of Symbols by Keyboard & Other tools
Usually Symbols
20
Display Display on Monitor
แสดงผล...
Display Display on Printer
Display
แสดงผล...
Display Display on other tools
Display data of Symbols by Keyboard & Other tools
Natural Language
21
Find x from equation x = (a+b-c)/100 ; if a, b, c manual
input from keyboard and display x on monitor.
Start
Program Sample;
Uses crt;
Input a, b, c Var a, b, c, x : real
Begin
x 0
display “Greater than Zero
Zero” on monitor no
End
26
if structure (Double Selection )
27
no yes
Process 2 Condition Process 1
if structure (Double Selection )
Input number 1
Begin
integer manual input
from keyboard,
brings the number to n
check number is 0,
Less than or no yes Greater than
if true display n>0
Equal to Zero Zero
“Greater than Zero”
and then false
display “Less than or
Equal to Zero” on End
monitor
28
Multi-Selection (if/else if/ else .. Structure)
29
yes no
Condition 1
yes no
Process 1 Condition 2
yes no
Process 2 Condition 3
Process 3 Process 4
Multi-Selection (if/else if/ else .. Structure)
30
Finding Grade Begin
score
0-49 E yes no
score>=80
50-59 D
Grade=’A’ yes no
score>=70
60-69 C
Grade=’B’ yes no
score>=60
70-79 B
Grade=’C’ yes no
score>=50
80-100 A
Grade=’D’ Grade=’E’
Manual input
from keyboard
and display on Grade
monitor End
case/switch Structure
31
yes
case 1 Process Process
no
yes
case 2 Process Process
no
yes
case n Process Process
no
Process
case/switch Structure
32
Begin
Manual input
from keyboard a,b
and display on choice
monitor yes
case 1 s=a+b s
Choice 1 + no
yes
case 2 s
Choice 2 – s=a-b
no
Choice 3 * case 3
yes s=a*b s
Choice 4 / no
yes
case 4 s=a/b s
no
End
Repetition
33
for
while
do .. while/repeat .. until
while .. Structure
34
yes
Condition Process
no
while .. Structure
35
Summations of Begin
number 1 – 10 with counter=0
sum=0
while loop
no
counter<=10
yes
counter=counter+1
sum=sum+counter
counter,sum
End
do while Structure & repeat until Structure
36
Process
yes
Condition
no
do while Structure & repeat until Structure
Summations of number Begin
1 – 10 with do-while counter=0
loop sum=0
counter=counter+1
sum=sum+counter
counter,sum
yes
Counter<=10
no
37
End
for Structure
38
Loop
Process
Process
for Structure
Summations of number Begin
1 – 10 with do-while
loop sum=0
counter=1,
counter<=10,
step 1
sum=sum+counter
counter,sum
39End
exercise
40
1. จงเขียนอัลกอริทึมแบบคาอธิบายและผังงาน ในการคานวณยอดชาระค่า
น้ าประปา โดยมีเงื่อนไขดังนี้
1 – 50 หน่ วย คิดหน่ วยละ 4.25 บาท
51 – 100 หน่ วย คิดหน่ วยละ 3.25 บาท
ตั้งแต่ 101 หน่ วยขึ้ นไป คิดหน่ วยละ 2.25 บาท
exercise
41
2.จงเขียนอัลกอริทึมแบบคาอธิบายและผังงาน เพื่อคานวณค่าเดินทาง
ั ั
โดยให้รบค่าระยะทาง 1 จานวน ซึ่งมีอตรา ดังนี้
n ระยะทาง 1 - 5 กิโลเมตร คิดค่าเดินทางกิโลเมตร 100 บาท
n ระยะทาง 6 - 10 กิโลเมตร คิดค่าเดินทางเพิ่ม จาก 5 กิโลเมตร คิด
กิโลเมตรละ 80 บาท
n ระยะทาง ตั้งแต่ 11 กิโลเมตรขึ้ น ไป คิดค่าเดินทางเพิ่ม จาก 10
กิโลเมตร คิดกิโลเมตรละ 60 บ
exercise
42
3.จงเขียนอัลกอริทึมแบบคาอธิบายและผังงาน ของ โปรแกรมตัดเกรด ดังนี้
A 80 – 100 B+ 79 - 75
B 74 – 70 C+ 69 - 65
C 64 – 60 D+ 59 - 55
D 54 – 50 F 49 - 0
โดยรับค่าอินพุท ้
ตั้งแต่ 0-100 ทางแปนพิมพ์