Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture #2: Introduction to Flowcharting مخططات الانسياب Dr. Hmood Al-Dossari King Saud University Department of Computer Science 13 February 2012.

Similar presentations


Presentation on theme: "Lecture #2: Introduction to Flowcharting مخططات الانسياب Dr. Hmood Al-Dossari King Saud University Department of Computer Science 13 February 2012."— Presentation transcript:

1 Lecture #2: Introduction to Flowcharting مخططات الانسياب Dr. Hmood Al-Dossari King Saud University Department of Computer Science 13 February 2012

2 Overview  What is a Flowchart? (المخططات الانسيابية)  Basic Flowchart Symbols (رموز واشكال المخططات الانسيابية)  Stepping Through the Flowchart (تتبع مخطط انسيابي)  Four Flowchart Structures (أنواع مخططات الانسياب)  Review (مراجعة)

3 What is a Flowchart?  It is a chart to describe the follow of the solution process.  رسم بياني لتمثيل سير برنامج لحل مشكلة معينة  The flowchart can be defined as a diagrammatic representation of an algorithm.  تمثيل رسومي لخوارزمية معينة START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END ابدأ اظهر رسالة كم عدد ساعات العمل؟ اقرأ ساعات العمل اظهر رسالة كم أجر الساعة؟ اقرأ أجر الساعة احسب الأجرة : اضرب عدد ساعات العمل في أجر الساعة اظهر النتيجة على الشاشة نهاية

4 Basic Flowchart Symbols  Notice there are three types of symbols in this flowchart: Rounded rectangles (بيضاوي) Parallelograms (متوازي المستطيلات) A rectangle (مستطيل)  Each symbol represents a different type of operation. START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Rounded Rectangle Parallelogram Rectangle Rounded Rectangle

5 Basic Flowchart Symbols  Terminals represented by rounded rectangles indicate a starting or ending point START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Terminal STARTEND Terminal

6 Basic Flowchart Symbols  Input/Output Operations represented by parallelograms indicate an input or output operation START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Display message “How many hours did you work?” Read Hours Input/Output Operation

7 Basic Flowchart Symbols  Input/Output Operations represented by parallelograms indicate an input or output operation START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Display message “How many hours did you work?” Read Hours Input/Output Operation

8 Basic Flowchart Symbols  Processes represented by rectangles indicates a process such as a mathematical computation or variable assignment START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Multiply Hours by Pay Rate. Store result in Gross Pay. Process

9 How many hours did you work? START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Variable Contents: Hours: ? Pay Rate: ? Gross Pay: ? Output Operation Stepping Through the Flowchart

10 How many hours did you work? 40 START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Variable Contents: Hours: 40 Pay Rate: ? Gross Pay: ? Input Operation (User types 40) Stepping Through the Flowchart

11 How much do you get paid per hour? START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Variable Contents: Hours: 40 Pay Rate: ? Gross Pay: ? Output Operation Stepping Through the Flowchart

12 How much do you get paid per hour? 20 START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Variable Contents: Hours: 40 Pay Rate: 20 Gross Pay: ? Input Operation (User types 20) Stepping Through the Flowchart

13 How much do you get paid per hour? START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Variable Contents: Hours: 40 Pay Rate: 20 Gross Pay: 800 Process: The product of 40 times 20 is stored in Gross Pay Stepping Through the Flowchart

14 Your gross pay is 800 START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read Pay Rate Multiply Hours by Pay Rate. Store result in Gross Pay. Display Gross Pay END Variable Contents: Hours: 40 Pay Rate: 20 Gross Pay: 800 Output Operation Stepping Through the Flowchart

15 Four Flowchart Structures  Sequence (متسلسل)  Decision (متفرع)  Repetition (دوران)  Case (متعدد)

16 Sequence Structure  a series of actions are performed in sequence  The pay-calculating example was a sequence flowchart.

17 Decision Structure  One of two possible actions is taken, depending on a condition.

18 Example  أرسم مخطط انسيابي يطلب درجة الطالب ومن ثم يحدد اذا كان ناجح او راسب ادخل درجة الطالب ابدأ اطبع نتيجة الطالب نهاية

19 Repetition Structure  A repetition structure represents part of the program that repeats. This type of structure is commonly known as a loop.

20 Repetition Structure  A loop tests a condition, and if the condition exists, it performs an action. Then it tests the condition again. If the condition still exists, the action is repeated. This continues until the condition no longer exists.

21 Example  أرسم مخطط انسيابي يطبع الأعداد من 1 الى 10 x=x+1 ابدأ أطبع X نهاية x=0

22 Controlling a Repetition Structure  ماهي مخرجات مخطط الانسياب التالي؟ أطبع X نهاية ابدأ x=0

23 Test  ماهي مخرجات مخططات الانسياب التالية؟ x=x+2 ابدأ أطبع X نهاية x=0 x=x+2 ابدأ أطبع X نهاية x=1

24 Case Structure  One of several possible actions is taken, depending on the contents of a variable.

25 Case Structure  The structure below indicates actions to perform depending on the value in years_employed. CASE years_employed 1 2 3 Other bonus = 100 bonus = 200 bonus = 400 bonus = 800

26 Case Structure CASE years_employed 1 2 3 Other bonus = 100 bonus = 200 bonus = 400 bonus = 800 If years_employed = 1, bonus is set to 100 If years_employed = 2, bonus is set to 200 If years_employed = 3, bonus is set to 400 If years_employed is any other value, bonus is set to 800

27 Combining Structures  Structures are commonly combined to create more complex algorithms.  The flowchart segment below combines a decision structure with a sequence structure. x < y? Display x Add 1 to x YES

28  This flowchart segment shows two decision structures combined.  مثال: اطبع العدد اذا كان بين 10 و20 Combining Structures Display “x is within limits.” Display “x is outside the limits.” YESNO x > min? x < max? YES NO Display “x is outside the limits.”

29 Review  What do each of the following symbols represent? (Answer on next slide)

30 Answer  What do each of the following symbols represent? Terminal Input/Output Operation Process Decision

31 Review  Name the four flowchart structures. (Answer on next slide)

32 Answer  Sequence (متسلسل)  Decision (متفرع)  Repetition (دوران)  Case (متعدد)

33  What type of structure is this? Review (Answer on next slide)

34 Answer  Repetition

35  What type of structure is this? Review (Answer on next slide)

36 Answer  Sequence

37  What type of structure is this? Review (Answer on next slide)

38 Answer  Case

39  What type of structure is this? Review (Answer on next slide)

40 Answer  Decision


Download ppt "Lecture #2: Introduction to Flowcharting مخططات الانسياب Dr. Hmood Al-Dossari King Saud University Department of Computer Science 13 February 2012."

Similar presentations


Ads by Google