107 Flowcharts
107 Flowcharts
A flowchart is a tool used to graphically represent an algorithm, which is a list of steps necessary to solve a problem or perform some activity. The flowchart consists of special geometric symbols containing a phrase to describe the step. The symbols are connected by arrows which describe the flow. The more commonly used symbols are: Symbol Name Flowline Description Connects symbols and shows the flow of the algorithm logic.
Terminal
Input/Output
Descibes data to be read into the program or printed and displayed by the program. Used to describe arithmetic and data-manipulation operations. Used for logic or comparison operations. The outflow path depends on the answer to the yes/no question asked.
Processing
Decision
Predefined Process
Connector
Offpage Connector
Arrows connecting flowchart symbols have two meanings: 1. They show the order in which the transformations are to be performed 2. They show the pathway or flow of given information going into a symbol and required information coming out. The most basic type of flowchart is the sequential flowchart. In this case, the flow proceeds from the beginning of the steps to the end without any branching operations. More sophisticated flowcharts make decisions which allow the program to branch depending on the outcome of an asked question.
107-Flowcharts.doc 9/6/2007
Page 1 of 3
EXAMPLE: Develop a flowchart for finding the area of a rectangle. The flowchart for this algorithm is:
A
Start
Get Length
Get Height
1 2 3 4 5 6 7 8 9 10 11 12 13
TITLE: DESCRIPTION:
Computes the area of a rectangle from the length and width parameters which are input by the user. Length = Height = 2 4
PARAMETERS:
CALCULATIONS:
Print Area
End
Start
Is X > Y?
Yes
Print Y, X
1 2 3 4 5 6 7 8 9 10 11 12 13
TITLE: DESCRIPTION:
PARAMETERS:
No Print X, Y
End
Note that there are other, maybe easier, ways to do this! Can you think of one?
107-Flowcharts.doc 9/6/2007
Page 2 of 3
An If-Block is a tool used to compare two things in programming. It does one set of steps if the condition specified is true, and another set of steps or nothing if the condition is false. The general structure is: IF condition THEN Step(s) if true ELSE Step(s) if false ENDIF The else and step(s) if false are optional. In structured programming, the ENDIF command is required to tell the computer that it has reached the end of the If-block. This command is not used in Excel. Sometimes, the ELSE commands can be another if-block. This technique is called nested ifs.
EXAMPLE: Develop a flowchart to determine if a number is greater than, less than, or equal to another number.
A
Start
Is X = Y?
Yes
1 2 3 4 5 6 7 8 9 10 11
TITLE: DESCRIPTION:
PARAMETERS:
Print EQUAL Cell Formula: D10: =IF(D6=D7,EQUAL,IF(D6>D7,X > Y,X < Y))
No Print X < Y
End
107-Flowcharts.doc 9/6/2007
Page 3 of 3