Presentation is loading. Please wait.

Presentation is loading. Please wait.

Flowcharts. Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in.

Similar presentations


Presentation on theme: "Flowcharts. Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in."— Presentation transcript:

1 Flowcharts

2 Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in an algorithm Process Symbol: Represents any single process in an algorithm Decision Symbol: Represents a decision in the logic involving the comparison Of two values. Predefined Process Symbol:

3 The three basic control structures

4 1. Sequence Statemement a Statemement b Statemement c

5 2. Selection Condition p? Statemement a Statemement b TF

6 Selection (2) Condition p? Statemement a T F

7 3. Repetition Condition p? Statemement block T F

8 Example 12.1 Add three numbers  A program is required to read three numbers, add them together and print their total.

9 Defining diagram InputProcessingOutput Number1 Number2 Number3 Read three numbers Add number together Print total number total

10 Solution Algorithm Add numbers to total Read Number1 Number2 number3 Print total Start Stop

11 Example 12.2 Find average temperature A program is required to prompt the terminal operator for the maximum and minimum temperature readings on a particular day, accept those readings as integers, and calculate and display to the screen the average temperature, calculated by (maximum temperature + minimum temperature)/2.

12 Defining diagram InputProcessingOutput Max_temp Min_temp Prompt for temperatures Get temperatures Calculate average temperature Display average temperature Avg_temp

13 Solution Algorithm

14 Example 12.3 Compute mowing time A program is required to read from the screen the lenght and widht of a rectangular house block, and the lenght and width of the rectangular house that has been built on the block. The algorithm should then compute and display the mowing time required to cut the grass around the house, at the rate of two square metres per minute.

15 Defining diagram InputProcessingOutput Block_lenght Block_width House_lenght House_width Prompt for block measurements Get block measurements Prompt for house measurements Get house measurements Calculate mowing area Calculate mowing time Mowing_time

16 Solution Algorithm

17 Flowchart and the selection control structure

18 Simple IF statement Account_ balance < $300? Service_charge = $5 Service_charge = $2 TF

19 Null ELSE statement

20 Combined IF statement

21 Nested IF statement Increment Counter_A Record Code =`A‘ ? Increment Counter_B Increment Counter_C Increment Error_counter Record Code =`B‘ ? Record Code =`C‘ ? T T T F F F

22 Example 12.4 Read three characters Design an algorithm that will prompt a terminal operator for three characters, accept those characters as input, sort them into ascending sequence and output them to the screen.

23 Defining diagram InputProcessingOutput Char_1 Char_2 Char_3 Prompt for characters Accept three characters Sort three characters Output three characters Char_1 Char_2 Char_3

24 Solution Algorithm ?

25 Case Structure Case Of variable Statement_aStatement_bStatement_cStatement_d Value 1 Value 2Value 3Value 4

26 Flowchart and Array Design a program that will prompt for and receive 18 examination scores from a mathematics test, compute the class average, and display all the scores and the class average to the screen.

27 Defining diagram InputProcessingOutput 18 exam scoresPrompt the scores Get scores Compute class average Display scores Display class average 18 exam scores Class_average

28 Control Structures required 1.An array to store the exam scores – called ´scores´ 2.An index to identify each element in the array 3.A DO loop to accept the scores 4.Another DO loop to display the scores to the screen.

29 Solution Algorithm Start Total_score = zero I = 1 Add scores(I) to Total score I = I + 1 Calculate average I = I + 1 Prompt and get Scores (I) I = 1 I <= 18 ? Display Scores (I) I <= 18 ? Display average Stop T F T F

30 Flowchart and Module Design a solution algorithm that will prompt a terminal operator for three characters, accept those characters as input, sort them into ascending sequence and output them to the screen. The algorithm is to continue to read characters until ´XXX`is entered.

31 Defining diagram InputProcessingOutput Char_1 Char_2 Char_3 Prompt for characters Accept three characters Sort three characters Output three characters Char_1 Char_2 Char_3

32 Hierarchy chart Process_three_ characters Sort_three_ characters

33 Process_three_characters Start Prompt For characters Sort_ Three_ characters Outpur characters Get characters Prompt For characters Get characters Stop Characters NOT = xxx ? F T

34 Sort_three_characters

35 Thanks Finish!


Download ppt "Flowcharts. Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in."

Similar presentations


Ads by Google