450 likes | 1.01k Views
FLOWCHART. Programming & Algorithm. Outline. Element of computer Computer language & Interpreter Analysis & Algorithm Algorithm structure . Element of computer. Computer language & Language Translator. Computer language Machine Language Low Level Language High Level Language
E N D
FLOWCHART Programming & Algorithm
Outline • Element of computer • Computer language & Interpreter • Analysis & Algorithm • Algorithm structure
Computer language & Language Translator Computer language • Machine Language • Low Level Language • High Level Language Language Translator • Assembler • Compiler • Interpreter
Analysis & Algorithm Analysis • Answer Analysis • Data Analysis • Process Analysis • Debug Analysis Algorithm • Flowchart • Pseudo code
Introduction to Flowchart • 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 • 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 • 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 • 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 inputrepresented by parallelogram, with the top irregularly sloping up from left to right. An example would be to signify data-entry from a form;
Symbol • 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)
Usually Symbols Read Reading of Keyboard Read Read Reading of other tools Reading data of Symbols by Keyboard & Other tools
Usually Symbols Display Display on Monitor แสดงผล... Display Display on Printer Display แสดงผล... Display Display on other tools Display data of Symbols by Keyboard & Other tools
Natural Language • 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; Var a, b, c, x : real Begin Clrscr; Readln(a,b,c); x := (a+b-c)/100 Writeln(x:8:2); End. Input a, b, c x <- (a+b-c)/100 x End
Algorithm structure • Sequential • Step to Step • Selection • Select part to true and false • Repetition • Loop
Sequential • Summations of 2 number define a, b by a, b manual input from keyboard and display answer on monitor.
Selection • Consist of 2 selection • if • switch
if structure (Single Selection ) • Input number 1 integer manual input from keyboard, brings the number to check number is 0, if true display “Greater than Zero” on monitor
if structure (Double Selection ) • Input number 1 integer manual input from keyboard, brings the number to check number is 0, • if true display “Greater than Zero” • and then false display “Less than or Equal to Zero” on monitor
Multi-Selection (if/else if/ else .. Structure) • Finding Grade • 0-49 E • 50-59 D • 60-69 C • 70-79 B • 80-100 A • Manual input from keyboard and display on monitor
case/switch Structure • Manual input from keyboard and display on monitor • Choice 1 + • Choice 2 – • Choice 3 * • Choice 4 /
Repetition • for • while • do .. while/repeat..until
Summations of number 1 – 10 with while loop while .. Structure
do while Structure & repeat until Structure • Summations of number 1 – 10 with do-while loop
for Structure • Summations of number 1 – 10 with do-while loop
exercise • 1. จงเขียนอัลกอริทึมแบบคำอธิบายและผังงาน ในการคำนวณยอดชำระค่าน้ำประปา โดยมีเงื่อนไขดังนี้ 1 – 50 หน่วย คิดหน่วยละ 4.25 บาท 51 – 100 หน่วย คิดหน่วยละ 3.25 บาท ตั้งแต่ 101 หน่วยขึ้นไป คิดหน่วยละ 2.25 บาท
exercise • 2.จงเขียนอัลกอริทึมแบบคำอธิบายและผังงาน เพื่อคำนวณค่าเดินทางโดยให้รับค่าระยะทาง 1 จำนวน ซึ่งมีอัตรา ดังนี้ n ระยะทาง 1 - 5 กิโลเมตร คิดค่าเดินทางกิโลเมตร 100 บาท n ระยะทาง 6 - 10 กิโลเมตร คิดค่าเดินทางเพิ่ม จาก 5 กิโลเมตร คิด กิโลเมตรละ 80 บาท n ระยะทาง ตั้งแต่ 11 กิโลเมตรขึ้น ไป คิดค่าเดินทางเพิ่ม จาก 10 กิโลเมตร คิดกิโลเมตรละ 60 บ
exercise • 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 ทางแป้นพิมพ์